Beispiel #1
0
        private float[] SigmaHidden(float[] input, float[,] wMapOut, float[] sigmaPrev, IFunction activationFunction)
        {
            activationFunction = activationFunction ?? new Linear();

            var xLength = wMapOut.GetLength(0);
            var yLength = wMapOut.GetLength(1);

            if (xLength != input.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(wMapOut));
            }
            if (yLength != sigmaPrev.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(wMapOut));
            }

            float[] sigmaHidden = new float[xLength];

            Parallel.For(0, xLength, x =>
            {
                var sigmaSum = 0F;
                for (var y = 0; y < yLength; y++)
                {
                    sigmaSum += wMapOut[x, y] * sigmaPrev[y];
                }
                sigmaHidden[x] = sigmaSum * activationFunction.Derevative(input[x]);
            });

            return(sigmaHidden);
        }
Beispiel #2
0
        public float[] ApplyDerivativeFunction(float[] vector, IFunction activationFunction)
        {
            activationFunction = activationFunction ?? new Linear();

            var result = new float[vector.Length];

            Parallel.For(0, vector.Length, i => { result[i] = activationFunction.Derevative(vector[i]); });
            return(result);
        }
Beispiel #3
0
        private float[] SigmaOut(float[] ideal, float[] input, IFunction activationFunction)
        {
            activationFunction = activationFunction ?? new Linear();

            float[] sigmaOut = new float[input.Length];

            Parallel.For(0, sigmaOut.Length, i => { sigmaOut[i] = (ideal[i] - activationFunction.Apply(input[i])) * activationFunction.Derevative(input[i]); });

            return(sigmaOut);
        }