예제 #1
0
        /// <summary>
        /// Returns outputs based on inputs going through the neural network
        /// </summary>
        /// <param name="_inputs"></param>
        /// <returns></returns>
        public float[] FeedForward(float[] _inputs)
        {
            // create matrix from inputs
            List <MatrixF> m = new List <MatrixF>();

            m.Add(MatrixF.FromArray(_inputs));

            // calculate hidden layers outputs
            for (int i = 0; i < numHiddenLayers; i++)
            {
                m.Add(MatrixF.DotProduct(weightMatrixes[i], m[i]));
                m[i + 1].Add(biasMatrixes[i]);
                Activate(m[i + 1]);
            }

            // calculate output layer output
            m.Add(MatrixF.DotProduct(weightMatrixes[weightMatrixes.Count - 1], m[m.Count - 1]));
            m[m.Count - 1].Add(biasMatrixes[biasMatrixes.Count - 1]);
            Activate(m[m.Count - 1]);

            return(MatrixF.ToArray(m[m.Count - 1]));
        }