Beispiel #1
0
        public SingleLayerNeuralNetwork(long inputsNumber, long outputsNumber, FirstDimensionUnitBuilder <IPerceptron> builder)
        {
            InputsNumber  = inputsNumber;
            OutputsNumber = outputsNumber;

            Layer  = new PerceptronLayer(OutputsNumber, builder);
            Layers = new object[] { Layer };
        }
Beispiel #2
0
        public OneHiddenLayerNeuralNetwork(long inputsNumber, long hiddensNumber, long outputsnumber, SecondDimensionUnitBuilder <IPerceptron> builder)
        {
            InputsNumber  = inputsNumber;
            HiddensNumber = hiddensNumber;
            OutputsNumber = outputsnumber;

            HiddenLayer = new PerceptronLayer(HiddensNumber, y => builder.Invoke(0, y));
            OutputLayer = new PerceptronLayer(OutputsNumber, y => builder.Invoke(1, y));
            Layers      = new object[2];
            Layers[0]   = HiddenLayer;
            Layers[1]   = OutputLayer;
        }
Beispiel #3
0
 public decimal[] CalculateGradients(PerceptronLayer nextLayer, decimal[] nextLayerGradients, decimal[] currentDerivatives)
 {
     decimal[] gradients = new decimal[Size];
     for (long c = 0; c < Size; c++)
     {
         decimal gradient = 0;
         for (long n = 0; n < nextLayer.Size; n++)
         {
             gradient += nextLayerGradients[n] * nextLayer.Units[n].Weights[c];
         }
         gradient    *= currentDerivatives[c];
         gradients[c] = gradient;
     }
     return(gradients);
 }