private void ComputeHiddenLayersProp(float[] outputsWished) { // Manage error for HiddenLayers values for (int k = HiddenLayerNb - 1; k >= 0; --k) { for (int i = 0; i < NeuronsPerHiddenLayer; ++i) { Neuron oneHidden = HiddenLayers[k].Neurons[i]; float totalError = 0.0f; // Modify values of last HiddenLayer using Output values for (int j = 0; j < oneHidden.NextNeuronsNb; ++j) { Neuron.Link link = oneHidden.NextLinks[j]; totalError += link.Error * link.Weight; } for (int j = 0; j < oneHidden.PreviousNeuronsNb; ++j) { float delta = totalError * oneHidden.ActivationValue * (1.0f - oneHidden.ActivationValue); Neuron.Link link = oneHidden.PreviousNeurons[j].GetLinkTowards(oneHidden); link.Error = delta; } } } }
private void ComputeFirstOutputBackprop(float[] outputsWished) { // Manage error with Output values for (int i = 0; i < OutputNb; ++i) { Neuron oneOutput = OutputLayer.Neurons[i]; // Modify values of last HiddenLayer using Output values for (int j = 0; j < NeuronsPerHiddenLayer; ++j) { float delta = -(outputsWished[i] - oneOutput.ActivationValue) * oneOutput.ActivationValue * (1.0f - oneOutput.ActivationValue); Neuron.Link link = HiddenLayers[HiddenLayerNb - 1].Neurons[j].GetLinkTowards(oneOutput); link.Error = delta; } } }