summaryrefslogtreecommitdiff
path: root/character_demo.html
diff options
context:
space:
mode:
authorAndrej <andrej.karpathy@gmail.com>2015-05-16 14:49:20 -0700
committerAndrej <andrej.karpathy@gmail.com>2015-05-16 14:49:20 -0700
commit3ba9014c4ae3bf89ae6ce49a17c03fffca13d3fe (patch)
treeffefcb53ea2cda26811c7794d75e0016a62477d0 /character_demo.html
parent003f557fa41c5f228c2e458711443e6d43e26cbe (diff)
parent2aae39f8c4b2548210959a4420504470ecb9abd7 (diff)
Merge pull request #2 from edouardklein/patch-1
Save and Load the solver as well.
Diffstat (limited to 'character_demo.html')
-rw-r--r--character_demo.html23
1 files changed, 22 insertions, 1 deletions
diff --git a/character_demo.html b/character_demo.html
index 143dc00..80a61a0 100644
--- a/character_demo.html
+++ b/character_demo.html
@@ -217,6 +217,17 @@ var saveModel = function() {
}
}
out['model'] = model_out;
+ var solver_out = {};
+ solver_out['decay_rate'] = solver.decay_rate;
+ solver_out['smooth_eps'] = solver.smooth_eps;
+ step_cache_out = {};
+ for(var k in solver.step_cache) {
+ if(solver.step_cache.hasOwnProperty(k)) {
+ step_cache_out[k] = solver.step_cache[k].toJSON();
+ }
+ }
+ solver_out['step_cache'] = step_cache_out;
+ out['solver'] = solver_out;
out['letterToIndex'] = letterToIndex;
out['indexToLetter'] = indexToLetter;
out['vocab'] = vocab;
@@ -235,6 +246,17 @@ var loadModel = function(j) {
model[k].fromJSON(matjson);
}
}
+ solver = new R.Solver(); // have to reinit the solver since model changed
+ solver.decay_rate = j.solver.decay_rate;
+ solver.smooth_eps = j.solver.smooth_eps;
+ solver.step_cache = {};
+ for(var k in j.solver.step_cache){
+ if(j.solver.step_cache.hasOwnProperty(k)){
+ var matjson = j.solver.step_cache[k];
+ solver.step_cache[k] = new R.Mat(1,1);
+ solver.step_cache[k].fromJSON(matjson);
+ }
+ }
letterToIndex = j['letterToIndex'];
indexToLetter = j['indexToLetter'];
vocab = j['vocab'];
@@ -242,7 +264,6 @@ var loadModel = function(j) {
// reinit these
ppl_list = [];
tick_iter = 0;
- solver = new R.Solver(); // have to reinit the solver since model changed
}
var forwardIndex = function(G, model, ix, prev) {