cazala / synaptic

architecture-free neural network library for node.js and the browser
http://caza.la/synaptic
Other
6.91k stars 666 forks source link

trainAsync syntax error #288

Open boyanyankov opened 6 years ago

boyanyankov commented 6 years ago

I tried the examples and enjoy testing this library -thanks for it.

When I tried trainAsync, it gives me a syntax error: ReferenceError: assignment to undeclared variable costFunction[Learn More] costFunction = 'var cost = ' + (options && options.cost || this.cost || _Trainer2.default.cost.MSE) + ';\n';

Code: myTrainer.trainAsync(trainingSet,{ rate: .1, iterations: 200, error: .01, shuffle: true, log: 100, cost: Trainer.cost.CROSS_ENTROPY }).then(results => console.log('done!', results));

It works with the regular train. Code: var trainingResult = myTrainer.train(trainingSet,{ rate: .1, iterations: 200, error: .01, shuffle: true, log: 100, cost: Trainer.cost.CROSS_ENTROPY });

wagenaartje commented 6 years ago

I think this is because you are running the JavaScript in strict mode. Try running it in non-strict mode to see if it still throws an error. It's weird, because it seems to be a declared variable in the source.