Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var layer_0 = X;
var layer_1 = nj.sigmoid(nj.dot(layer_0, synapse_0));
if(dropout) {
// I don't understand what this does yet
// layer_1 *= nj.random.binomial([np.ones((len(X),hidden_neurons))], 1-dropout_percent)[0] * (1.0/(1-dropout_percent));
}
var layer_2 = nj.sigmoid(nj.dot(layer_1, synapse_1));
var layer_2_error = y.subtract(layer_2);
if( (j % 10000) == 0 && j > 5000 ) {
// if this 10k iteration's error is greater than
// the last iteration, break out
if (nj.mean(nj.abs(layer_2_error)) < last_mean_error) {
console.log("delta after " + j + " iterations:" + nj.mean(nj.abs(layer_2_error)) );
last_mean_error = nj.mean(nj.abs(layer_2_error));
} else {
console.log ("break:" + nj.mean(nj.abs(layer_2_error)) + ">" + last_mean_error );
break;
}
}
var layer_2_delta = layer_2_error.multiply( curve(layer_2) );
var layer_1_error = layer_2_delta.dot(synapse_1.T);
var layer_1_delta = layer_1_error.multiply( curve(layer_1) );
var synapse_1_weight_update = (layer_1.T.dot(layer_2_delta));
var synapse_0_weight_update = (layer_0.T.dot(layer_1_delta));
if(j > 0) {
synapse_0_direction_count = synapse_0_direction_count.add(