internal void ApplyLearning(NeuralLayer neuralLayer, double learningRate) { foreach (var item in Input) { item.ApplyLearning(learningRate); } lastdelta = delta; weight += delta * learningRate; }
internal void InitiateLearning(NeuralLayer neuralLayer) { foreach (var item in Input) { item.LastDeltaWeight = 0; item.DeltaWeight = 0; } delta = 0; lastdelta = 0; }
internal void Pulse(NeuralLayer neuralLayer) { Output = 0; foreach (var item in Input) { Output += item.Input.Output * item.Weight; } Output += bias; Output = ActivateFunction(Output); }
public void Init(int seed, int inputNeurons, int hiddenNeurons, int outputNeurons) { inputLayer = new NeuralLayer(); hiddenLayer = new NeuralLayer(); outputLayer = new NeuralLayer(); fitness = 100; this.seed = seed; Random rand = new Random(this.seed); Random rand2 = new Random(this.seed); Random rand3 = new Random(this.seed); Random rand4 = new Random(this.seed); int i, j; for (i = 0; i < inputNeurons; i++) { inputLayer.neurons.Add(new Neuron(0)); } for (i = 0; i < hiddenNeurons; i++) { hiddenLayer.neurons.Add(new Neuron(rand.NextDouble())); } for (i = 0; i < outputNeurons; i++) { outputLayer.neurons.Add(new Neuron(rand2.NextDouble())); } //Wire input together with the hidden layer for (i = 0; i < hiddenLayer.neurons.Count; i++) { for (j = 0; j < inputLayer.neurons.Count; j++) { hiddenLayer.neurons[i].Input.Add(new Link(inputLayer.neurons[j], rand3.NextDouble())); } } //Wire output together with hidden layer for (i = 0; i < outputLayer.neurons.Count; i++) { for (j = 0; j < hiddenLayer.neurons.Count; j++) { outputLayer.neurons[i].Input.Add(new Link(hiddenLayer.neurons[j], rand4.NextDouble())); } } }