diff options
author | edouardklein <edouardk.lei.n@gmail.com> | 2015-05-16 22:02:54 +0200 |
---|---|---|
committer | edouardklein <edouardk.lei.n@gmail.com> | 2015-05-16 22:02:54 +0200 |
commit | 2aae39f8c4b2548210959a4420504470ecb9abd7 (patch) | |
tree | ffefcb53ea2cda26811c7794d75e0016a62477d0 /character_demo.html | |
parent | 003f557fa41c5f228c2e458711443e6d43e26cbe (diff) |
Save and Load the solver as well.
Somebody noticed a spike in perplexity after loading the model. This spike disappears if we save and load the solver as well.
Diffstat (limited to 'character_demo.html')
-rw-r--r-- | character_demo.html | 23 |
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) { |