コード例 #1
0
 public PerceptronNetwork(double[] input, int neuronsAmount)
 {
     Input = input;
     Neurons = new Neuron[neuronsAmount];
     for (int i = 0; i < neuronsAmount; i++)
         Neurons[i] = new Neuron(Input, 0.1);
 }
コード例 #2
0
        public MultiLayerPerceptronNetwork(double[] input, int hiddenLayerAmount, int outLayerAmount, double learningRate)
        {
            Input = input;
            LearningRate = learningRate;

            // Allocating Hidden Layer
                HiddenLayer = new Neuron[ hiddenLayerAmount ];
                // Instantiating Neurons from Hidden Layer
                for (int i = 0; i < HiddenLayer.Length; i++)
                    HiddenLayer[i] = new Neuron(LearningRate);
            //

            // Allocating Output Layer
                OutLayer = new Neuron[ outLayerAmount ];
                // Instantiating Neurons from Output Layer
                for (int i = 0; i < OutLayer.Length; i++)
                    OutLayer[i] = new Neuron(LearningRate);
            //

            // Setting Weights manually
            SetManuallyWeights();

            // Set input on the hidden layer
            SetInputOnHiddenLayer();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: diasssavio/NeuralNetwork
        static void BackwardNeuron()
        {
            Neuron neuron = new Neuron(0.1);
            neuron.Weights = new double[] { -1.0, 1.0, 0.5 };

            for (int i = 1; i <= 10; i++)
            {
                neuron.Backward(new double[] { -1.0, -1.0 }, -1.0);
                Console.WriteLine("{0}: -1.0, -1.0 = {1:f6}", i, neuron.Output);

                neuron.Backward(new double[] { 1.0, -1.0 }, -1.0);
                Console.WriteLine("{0}: 1.0, -1.0 = {1:f6}", i, neuron.Output);

                neuron.Backward(new double[] { -1.0, 1.0 }, -1.0);
                Console.WriteLine("{0}: -1.0, 1.0 = {1:f6}", i, neuron.Output);

                neuron.Backward(new double[] { 1.0, 1.0 }, 1.0);
                Console.WriteLine("{0}: 1.0, 1.0 = {1:f6}", i, neuron.Output);

                Console.WriteLine();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: diasssavio/NeuralNetwork
        static void ForwardNeuron()
        {
            double[] inputs = { -1.0, -1.0 };
            // { bias, entradas... }
            double[] weights = { -0.1, 0.4, 0.1 };

            Neuron neuron = new Neuron(inputs, 0.1);
            neuron.Weights = weights;
            neuron.Forward();

            Console.WriteLine("bias: {0}", Neuron.Bias);

            Console.Write("Inputs: ");
            foreach (double value in neuron.Input)
                Console.Write("{0:f4}  ", value);
            Console.WriteLine();

            Console.Write("Weights:");
            foreach (double value in neuron.Weights)
                Console.Write("{0:f4}  ", value);
            Console.WriteLine();

            Console.Write("Output: {0:f4}", neuron.Output);
        }