Exemplo n.º 1
0
 public void AdjustWeights(int inputIndex, double[] inputs)
 {
     for (var i = 0; i < _numNeurons; i++)
     {
         _hiddenWeights[i] -= (_outputData[inputIndex] - _expectedOutput[inputIndex]) * inputs[i] * _learnRate;
         for (var j = 0; j < _numLearnNeurons; j++)
         {
             _inputWeights[j, i] -= (_outputData[inputIndex] - _expectedOutput[inputIndex]) *
                                    Sigmoid.Derivative(inputs[i]) * _hiddenWeights[i] * _outputData[inputIndex] *
                                    _learnRate;
         }
     }
 }
Exemplo n.º 2
0
 public void Train(int inputIndex, double[] inputs)
 {
     for (var i = 0; i < _numNeurons; i++) //neuron
     {
         inputs[i] = 0.0;
         for (var j = 0; j < _numLearnNeurons; j++) //weight
         {
             inputs[i] += _inputData[inputIndex] * _inputWeights[j, i];
         }
         inputs[i] = Sigmoid.Func(inputs[i]);
     }
     _outputData[inputIndex] = 0.0;
     for (var i = 0; i < _numNeurons; i++)
     {
         _outputData[inputIndex] += _hiddenWeights[i] * inputs[i];
     }
 }