Exemple #1
0
        public Network(int numInputParameters, int numNeuronsInHiddenLayer, int numOutputParameters, int maxEpochs)
        {
            InputLayer = new Layer();
            HiddenLayer = new Layer();
            OutputLayer = new Layer();
            MaxEpochs = maxEpochs;

            //Setup Input Layer
            for (var i = 0; i < numInputParameters; i++)
            {
                InputLayer.Neurons.Add(new Neuron(1, true));
            }

            //Setup Hidden Layer
            for (var i = 0; i < numNeuronsInHiddenLayer; i++)
            {
                var neuron = new Neuron(numInputParameters);
                neuron.RandomizeWeights();
                HiddenLayer.Neurons.Add(neuron);
            }

            //Setup Output Layer
            for (var i = 0; i < numOutputParameters; i++)
            {
                var neuron = new Neuron(HiddenLayer.Neurons.Count);
                neuron.RandomizeWeights();
                OutputLayer.Neurons.Add(neuron);
            }
        }
Exemple #2
0
 private void BackPropagate(Neuron outputNeuron)
 {
     for (var neuronIndex = 0; neuronIndex < HiddenLayer.Neurons.Count; neuronIndex++)
     {
         var neuron = HiddenLayer.Neurons[neuronIndex];
         neuron.Error = Sigmoid.Derivative(neuron.Output) * outputNeuron.Error * outputNeuron.Weights[neuronIndex];
         neuron.AdjustWeights();
     }
 }