Esempio n. 1
0
 private void CorrectionLayerWeight(Neuron[] layer, double[] layerError)
 {
     const double learningSpeed = 0.8;
     for (int j = 0; j < layer.Count(); j++)
     {
         for (int i = 0; i < layer[j].EntrancesWeight.Count(); i++)
         {
             var delta = (-1) * learningSpeed * layerError[j] * layer[j].EntranceValue[i];
             layer[j].EntrancesWeight[i] += delta;
         }
     }
 }
Esempio n. 2
0
        private double[] ErrorInLayer(double alpha, Neuron[] currentLayer, Neuron[] nextLayer, double[] nextLayerError)
        {
            var layerError = new double[currentLayer.Count()];

            for (int i = 0; i < layerError.Count(); i++)
            {
                double weight = 0;
                for (int j = 0; j < nextLayer.Count(); j++)
                {
                    weight += nextLayer[j].EntrancesWeight[i] * nextLayerError[j];
                }
                layerError[i] = alpha * currentLayer[i].ActivateFunction() * (1 - currentLayer[i].ActivateFunction()) * weight;
            }
            return layerError;
        }
Esempio n. 3
0
        private double[] GetLayerEntrance(Neuron[] layer, double[] inputValue)
        {
            foreach (var value in layer)
                value.Entrance(inputValue);

            var intermediateResult = new double[layer.Count()];
            for (int i = 0; i < layer.Count(); i++)
                intermediateResult[i] = layer[i].ActivateFunction();
            return intermediateResult;
        }
Esempio n. 4
0
 private void FillNeyronLayer(Neuron[] layer, Random rnd, int entrancesNumber)
 {
     for (int i = 0; i < layer.Count(); i++)
         layer[i] = new Neuron(entrancesNumber, rnd.Next(10000));
 }