BrainJS / BrainJS/brain.js

Train imported model from JSON fails

Open
#741 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
14.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Trying to train an imported model from JSON fails.

Use case:
```typescript
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
```typescript
dataFormatter.isSetup = true;
```
So is there any drawback for this Fix ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.