Beispiel #1
0
        public void Train(double[,] training_inputs, double[] training_outputs, int training_iterations)
        {
            for (int i = 0; i < training_iterations; i++)
            {
                double[] outputs     = new double[training_inputs.Length / synaptic_weights.Length];
                double[] error       = new double[training_inputs.Length / synaptic_weights.Length];
                double[] adjustments = new double[training_inputs.Length / synaptic_weights.Length];

                outputs = Think(training_inputs);
                error   = NNMath.createError(training_outputs, outputs);

                adjustments = NNMath.createAdjustments(error, training_inputs, outputs, synaptic_weights.Length);

                synaptic_weights = NNMath.AdjustWeights(synaptic_weights, adjustments);
            }
        }
Beispiel #2
0
        public static double[] createAdjustments(double[] error, double[,] inputs, double[] outputs, int numofweights)
        {
            double[] adjustments = new double[numofweights];

            for (int i = 0; i < numofweights; i++)
            {
                double adjust = 0;

                for (int y = 0; y < error.Length; y++)
                {
                    adjust += error[y] * inputs[y, i] * NNMath.Sigmoid_Derivative(outputs[y]);
                }

                adjustments[i] = adjust;
            }

            return(adjustments);
        }
Beispiel #3
0
        public double[] Think(double[,] inputs)
        {
            double[] outputs = new double[inputs.Length / synaptic_weights.Length];

            for (int i = 0; i < outputs.Length; i++)
            {
                double output = 0;

                for (int j = 0; j < 3; j++)
                {
                    output += inputs[i, j] * synaptic_weights[j];
                }

                outputs[i] = NNMath.Sigmoid(output);
            }

            return(outputs);
        }