Exemple #1
0
        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];
            }
        }
Exemple #2
0
        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];
                }
            }
        }
Exemple #3
0
 public void BackPropagate(Layer nextLayer) {
     for (int c = 0; c < Weights.Length; c++)
         Delta += nextLayer[c].Delta * Weights[c];
 }
Exemple #4
0
 public void ForwardPropagate(Layer nextLayer) {
     for (int c = 0; c < Weights.Length; c++)
         nextLayer[c].Value += Value * Weights[c];
 }
Exemple #5
0
        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();
        }
Exemple #6
0
        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);
        }