I think what might be going on is that what you’re passing into BrainJS is not actually JSON.
In your code, you have this:
fs.readFile('traindata.json', function(err, data) {
if (err) throw err;
net.fromJSON(data);
console.log("file loaded");
});
When I tried running your code, I saw the same error you saw.
Using JSON.parse()
seemed to fix the issue.
In other words, when I changed net.fromJSON(data);
to net.fromJSON(JSON.parse(data));
, the error disappeared.
CLICK HERE to find out more related problems solutions.