예제 #1
0
        public FloatMatrix ForwardPropagation(FloatMatrix InputValue)
        {
            FloatMatrix[] Z = new FloatMatrix[LayerCount];
            FloatMatrix[] A = new FloatMatrix[LayerCount];

            Z[0] = InputValue.AddColumn(FloatMatrix.Ones(InputValue.x, 1));
            A[0] = Z[0];

            for (int i = 1; i < LayerCount; i++)
            {
                Z[i] = (A[i - 1] * W[i - 1]).AddColumn(FloatMatrix.Ones(InputValue.x, 1));

                if (activationFunction == ActivationFunction.Relu)
                {
                    A[i] = Relu(Z[i]);
                }
                else if (activationFunction == ActivationFunction.Sigmoid)
                {
                    A[i] = Sigmoid(Z[i]);
                }
            }
            return(Z[Z.Length - 1].Slice(0, 1, Z[Z.Length - 1].x, Z[Z.Length - 1].y));
        }