brain.js
brain.js copied to clipboard
Train imported model from JSON fails
Trying to train an imported model from JSON fails.
Use case:
let net = new LSTM();
const trainingData = [
{
input: 'hi',
output: 'mom',
},
{
input: 'howdy',
output: 'dad',
},
{
input: 'hello',
output: 'sis',
},
{
input: 'yo',
output: 'bro',
},
];
net.train(trainingData, { iterations: 20 });
const net2 = new LSTM().fromJSON(net.toJSON());
net2.train(trainingData, { iterations: 20 });
net2.run('hi');
Error:
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 (brain.js\src\recurrent\rnn.ts:628:15)
Fix: Setting dataFormatter.isSetup to true in DataFormatter.fromJSON solve the problem
dataFormatter.isSetup = true;
So is there any drawback for this Fix ?
I am actually at this point too. Anything new?
Same problem. I store the model in a json, try to load it, but it just fails with the same error.
This has been resolved in https://www.npmjs.com/package/brain.js/v/2.0.0-beta.11. Here is a working example: https://observablehq.com/@robertleeplummerjr/brain-js-issue-741.
This isn't solved. When trying to train the model after loading fromJSON, it still fails as they describe in the issue:

It's the same issue as #787
Thanks for reproducing. I'll look at this early this week.
Thanks for reproducing. I'll look at this early this week.
Any progress on figuring this out? This is pretty much useless without being able to save a previous network.