from.connected is not a function
This looks like a great project, but:
When attempting the tutorial code, I keep getting this error: from.connected is not a function
I'm trying to run directly in the browser.
What code are you exactly running? We can't help you if we don't no what is going wrong...
Thanks for your reply
I'm running html/js code with the html loading synaptic as follows:
The javascript is as follows: var Neuron = synaptic.Neuron, Layer = synaptic.Layer, Network = synaptic.Network, Trainer = synaptic.Trainer, Architect = synaptic.Architect; var myNetwork = new Architect.Perceptron(2, 2, 1);
Seems to working fine here... jsfiddle
Thanks for your trouble - after reviewing your fiddle, I realised that when i comment out one of the js files that was I loading in my project - which does some prototype changing - it works.
I have tracked down the specific overloads / prototype changes that created the conflict. I am pasting here in case other coders are using these overloads. There were two conflicting codeblocks: // Number 1 /////////////////////////////////////////////////////// if (!Array.prototype.joinWith) { +function () { Array.prototype.joinWith = function(that, by, select, omit) { var together = [], length = 0; if (select) select.map(function(x){select[x] = 1;}); function fields(it) { var f = {}, k; for (k in it) { if (!select) { f[k] = 1; continue; } if (omit ? !select[k] : select[k]) f[k] = 1; } return f; } function add(it) { var pkey = '.'+it[by], pobj = {}; if (!together[pkey]) together[pkey] = pobj, together[length++] = pobj; pobj = together[pkey]; for (var k in fields(it)) pobj[k] = it[k]; } this.map(add); that.map(add); return together; } }(); }
// Number 2 ////////////////////////////////////////////////////////// Array.prototype.clone = function() { return jQuery.extend(true, [], this); };
Many thanks for your help. This is an excellent library!
I'm seeing the same error with EmberJS, which seems to alter the built-in Array. This creates a __proto__ attribute in any array that will also get iterated over when you do for (var x in y).
I would like to see synaptic drop the use of for (var x in y) for iterating over arrays (layers, neurons, etc.), since it is generally not recommended. See discussion here, for example:
https://stackoverflow.com/a/500531/1571826
I have actually created a PR yesterday that removes all those incorrect loops. So stay tuned :)
That's awesome news. I see it's been merged. Bedankt!