transcranial / keras-js

Run Keras models in the browser, with GPU support using WebGL
https://transcranial.github.io/keras-js
MIT License
4.96k stars 503 forks source link

Cannot read property 'tensor' of undefined #106

Open lemoustachiste opened 6 years ago

lemoustachiste commented 6 years ago

Hi,

I've been struggling all morning with this issue, and I can't seem to figure out why it fails. I have a model of which the input is of Dense type. As I predict, I receive the error in the title, breaking on that line: https://github.com/transcranial/keras-js/blob/master/src/Model.js#L579

I looked in depth, I have 9 model layers defined, according to the original model I defined with the bin file. The last layer seems to be correctly set as the outputLayer.

If I inspect all my layers, only the first one (the input) has an output key. The rests do not, including obviously the outputLayer.

I am a bit at a loss here, since I have limited knowledge of ML in general and Keras in particular. Is there anything that has been done wrong in my initial definition of layers? Or something else that I'd be missing in a configuration?

Thanks for the help

hepesu commented 6 years ago

Maybe you run your prediction too early. You can bind "initProgress" event to see whether the model is initialized or not. If the model is not fully initialized, it would throw this error.