Пример #1
0
 void SetSigmas(double[] outputs)
 {
     sigma = new List <double[]>();
     for (int i = 0; i < capas.Count; i++)
     {
         sigma.Add(new double[capas[i].neuronas.Count]);
     }
     for (int i = capas.Count - 1; i >= 0; i--)
     {
         for (int j = 0; j < capas[i].neuronas.Count; j++)
         {
             if (i == capas.Count - 1)
             {
                 double y = capas[i].neuronas[j].ultimaActivacion;
                 sigma[i][j] = (Neurona.Sigmoide(y) - outputs[j]) * Neurona.SigmaideDerivada(y);
             }
             else
             {
                 double sum = 0;
                 for (int k = 0; k < capas[i + 1].neuronas.Count; k++)
                 {
                     sum += capas[i + 1].neuronas[k].pesos[j] * sigma[i + 1][k];
                 }
                 sigma[i][j] = Neurona.SigmaideDerivada(capas[i].neuronas[j].ultimaActivacion) * sum;
             }
         }
     }
 }
Пример #2
0
 void AddDelta()
 {
     for (int i = 1; i < capas.Count; i++)
     {
         for (int j = 0; j < capas[i].neuronas.Count; j++)
         {
             for (int k = 0; k < capas[i].neuronas[j].pesos.Length; k++)
             {
                 deltas[i][j, k] += sigma[i][j] * Neurona.Sigmoide(capas[i - 1].neuronas[k].ultimaActivacion);
             }
         }
     }
 }