Database Reference
In-Depth Information
The pieces of the backpropagation algorithm are finally assembled in the
train method of the NeuralNetwork class in this example. The training
example—consisting of an input array, x, and an output array, y—is then fed
through the network to produce an output:
public NeuralNetwork train( double [] x, double [] y) {
double [] out = feed(x);
The difference between the output and the input is then calculated and
propagated backward through the network:
double [] s = new double [out.length];
for ( int i=0;i<y.length;i++) s[i] = y[i] - out[i];
for ( int i=layers.size()-1;i>=0;i--) s =
layers.get(i).backprop(s);
Finally, each layer's weights are updated by walking forward through each
layer:
for (Layer l : layers) x = l.update(x, learningRate);
return this ;
}
Search WWH ::




Custom Search