cazala / synaptic

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

Cannot read property 'train' of undefined #287

Closed rob-gordon closed 3 years ago

rob-gordon commented 6 years ago

If I try to run exactly the dead simple LSTM example posted here: https://github.com/cazala/synaptic/issues/217

I still get the error

const trainResults = lstm.trainer.train(trainSet, trainOptions);
                                ^

TypeError: Cannot read property 'train' of undefined
    at Object.<anonymous> (/Users/robgordon/dev/data/test.com/easyTest.js:29:35)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Function.Module.runMain (module.js:682:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:613:3

Do I have the wrong version of Node running maybe?

rob-gordon commented 6 years ago

As a test I jumped back to synaptic version 1.0.0 and then the example from https://github.com/cazala/synaptic/issues/217 worked. Still not clear exactly why?

ghost commented 6 years ago

I got the same a while ago and used the XOR trainingset to test the basics, than rewrote my trainingset code from scratch. I must have had a bug in the creation of my trainingset and the recent Synaptic code is more bitchy to detect broken training data.

counterbeing commented 6 years ago

I just tried the exact same thing. It appears that the trainer property on the LSTM has been removed. Seems like you now much instantiate your own trainer, maybe something like this?

const network = new Architect.LSTM(2, 10, 2)
const trainer = new Trainer(network)
trainer.train(trainingData, options)

I can see that the v1.0.0 LSTM architect adds a trainer to the instance, and it no longer appears to.