public void Adjust(Layer nextLayer) { const double alpha = 0.075; for (int c = 0; c < Weights.Length; c++) { DeltaWeights[c] = alpha * DeltaWeights[c] + (1.0 - alpha) * Perceptron.LearningRate * nextLayer.Neurons[c].Delta * Value; Weights[c] += DeltaWeights[c]; } }
public Layer(int size, Layer next) { Neurons = new Neuron[size]; this.next = next; for (int j = 0; j < Length; j++) { Neurons[j] = new Neuron(); if (next != null) { Neurons[j].Weights = new double[next.Length]; Neurons[j].DeltaWeights = new double[next.Length]; } } }
public void BackPropagate(Layer nextLayer) { for (int c = 0; c < Weights.Length; c++) Delta += nextLayer[c].Delta * Weights[c]; }
public void ForwardPropagate(Layer nextLayer) { for (int c = 0; c < Weights.Length; c++) nextLayer[c].Value += Value * Weights[c]; }
public void Load(string filePath) { Stream stream = File.OpenRead(filePath); BinaryReader reader = new BinaryReader(stream); layers = new Layer[reader.ReadInt32()]; for (int i = layers.Length - 1; i >= 0; i--) layers[i] = new Layer(reader.ReadInt32(), i < layers.Length - 1 ? layers[i + 1] : null); for (int i = layers.Length - 1; i >= 0; i--) layers[i].Load(reader); stream.Close(); }
public Perceptron(int[] layersSizes) { layers = new Layer[layersSizes.Length]; for (int i = layers.Length - 1; i >= 0; i--) layers[i] = new Layer(layersSizes[i], i < layers.Length - 1 ? layers[i + 1] : null); }