public void BackwardPropagationOutput(double[] expected, ITransferFunction transferFunction) { for (int i = 0; i < numberOfOutputs; i++) { error[i] = outputs[i] - expected[i]; } for (int i = 0; i < numberOfOutputs; i++) { gamma[i] = error[i] * transferFunction.Derivative(outputs[i]); } for (int i = 0; i < numberOfOutputs; i++) { for (int j = 0; j < numberOfInputs; j++) { weightsDelta[i, j] = gamma[i] * inputs[j]; } } }
public void BackwardPropagationHidden(double[] gammaForward, double[,] weightsForward, ITransferFunction transferFunction) { for (int i = 0; i < numberOfOutputs; i++) { gamma[i] = 0; for (int j = 0; j < gammaForward.Length; j++) { gamma[i] += gamma[j] * weightsForward[j, i]; } gamma[i] *= transferFunction.Derivative(outputs[i]); } for (int i = 0; i < numberOfOutputs; i++) { for (int j = 0; j < numberOfInputs; j++) { weightsDelta[i, j] = gamma[i] * inputs[j]; } } }