public double Run( double[] input, double[] output )
{
// compute output of network
double[] networkOutput = network.Compute( input );
// get the only layer of the network
Layer layer = network.Layers[0];
// summary network absolute error
double error = 0.0;
// check output of each neuron and update weights
for ( int j = 0; j < layer.Neurons.Length; j++ )
{
double e = output[j] - networkOutput[j];
if ( e != 0 )
{
ActivationNeuron perceptron = layer.Neurons[j] as ActivationNeuron;
// update weights
for ( int i = 0; i < perceptron.Weights.Length; i++ )
{
perceptron.Weights[i] += learningRate * e * input[i];
}
// update threshold value
perceptron.Threshold += learningRate * e;
// make error to be absolute
error += Math.Abs( e );
}
}
return error;
}