brain.js
brain.js copied to clipboard
Unable to train recurrent.LSTM() after loading previous training fromJSON()
What is wrong?
In other classes, such as NeuralNetwork(), I am able to save a trained model by using toJSON(), and load it later with fromJSON(), in order to continue training.
When I try to do this with recurrent.LSTM(), training fails with the following error:
/app/node_modules/brain.js/dist/index.js:7586
throw new Error('Network error rate is unexpected NaN, check network configurations and try again. Most probably input format is not correct or training data is not enough. ');
^
Error: Network error rate is unexpected NaN, check network configurations and try again. Most probably input format is not correct or training data is not enough.
at LSTM.train (/app/node_modules/brain.js/dist/index.js:7586:23)
at file:///app/src/js/model.js:56:5
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
at async loadESM (node:internal/process/esm_loader:85:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Node.js v17.9.0
Where does it happen?
This is happening in Node.JS on Ubuntu 20.04.
How do we replicate the issue?
Execute this bit of code to reproduce the problem.
import brain from 'brain.js'
let net = new brain.recurrent.LSTM()
net.train([
'doe, a deer, a female deer',
'ray, a drop of golden sun',
], {
iterations: 500,
log: true,
errorThresh: 0.01
})
let saved = net.toJSON()
net.fromJSON(saved)
net.train([
'me, a name I call myself',
], {
iterations: 500,
log: true,
errorThresh: 0.01
})
Expected behavior (i.e. solution)
I would expect training to resume from where it left off previously. In other classes, I am able to save my network to disk, and restart training with it later. I'm unable to do that with recurrent.LSTM().
This is particularly desired because recurrent.LSTM() is quite slow, and I don't want to retrain my entire network if the training data changes.
Version information
Nodejs: 17.9.0
Brain.js: 2.0.0-beta.15
How important is this (1-5)?
Probably a 1. I'm new to AI and I'm guessing this limitation is by-design?
Other Comments
Thanks in advance for any help you can offer!
Hello there! I have the same problem. Any news about it?
+1, I've got this issue too.
+1
+1
Investigating.
Published in version https://www.npmjs.com/package/brain.js/v/2.0.0-beta.16