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

Standalone output ignores input #263

Open morungos opened 6 years ago

morungos commented 6 years ago

I found what seems to be a typo that is breaking standalone generated output. Basically, the generated function ignores the input entirely. There aren't even any references to it in the generated code.

The culprit seems to be: https://github.com/cazala/synaptic/blob/master/src/Network.js#L430

Current code:

    for (var i = 0; i < data.inputs; i++)
      activation += 'F[' + data.inputs[i] + '] = input[' + i + '];\n';

Should probably read:

    for (var i = 0; i < data.inputs.length; i++)
      activation += 'F[' + data.inputs[i] + '] = input[' + i + '];\n';

i.e., don't use the array as if it's an integer in loop condition.

The effect of this, at least for me in Node.js, is to omit all initialization from input.