Beispiel #1
0
 public SecondLayer(FirstLayer Layer, int nElements, Weight Weights)
 {
     Result       = new double[nElements];
     ResultLength = nElements;
     for (int x = 0; x < nElements; x++)
     {
         if (Result[x] != 0)
         {
             Result[x] = 0;
         }
         for (int y = 0; y < Layer.HiddenLength; y++)
         {
             Result[x] += Layer.Hidden[y] * Weights.Body[y, x];
         }
         Result[x] = MathAI.Sigmoid(Result[x]);
     }
 }
Beispiel #2
0
        public SecondLayer(FirstLayer Layer, int nElements, Weight Weights, int Answer)
        {
            Result       = new double[nElements];
            ResultLength = nElements;
            for (int x = 0; x < nElements; x++)
            {
                if (Result[x] != 0)
                {
                    Result[x] = 0;
                }
                for (int y = 0; y < Layer.HiddenLength; y++)
                {
                    Result[x] += Layer.Hidden[y] * Weights.Body[y, x];
                }
                Result[x] = MathAI.Sigmoid(Result[x]);
            }
            double sumResult = 0;

            for (int i = 0; i < nElements; i++)
            {
                sumResult += Result[i];
            }
            ResultAccuracy = Result[Answer] / sumResult;
        }
Beispiel #3
0
        public FirstLayer(Digit Enter, int dimHiddenLayer, Weight Weights)
        {
            int layerlength = Enter.pixelWidth * Enter.pixelHeight;

            curLayer = Enter.LineMatrix;

            Hidden       = new double[dimHiddenLayer];
            HiddenLength = dimHiddenLayer;

            //layer[0] = 1;
            for (int x = 0; x < dimHiddenLayer; x++)
            {
                if (Hidden[x] != 0)
                {
                    Hidden[x] = 0;
                }
                for (int y = 0; y < layerlength; y++)
                {
                    Hidden[x] += curLayer[y] * Weights.Body[y, x];
                }
                Hidden[x] = MathAI.Sigmoid(Hidden[x]);
            }
            //return hidden;
        }