Пример #1
0
        public void ChangeDeltaForSynaps(Synaps synaps, double currentNeuronDelta)
        {
            double delta = synaps.LastWeightChange * Momentum + learningSpeed * synaps.FirstNeuron.Output * currentNeuronDelta;

            synaps.LastWeightChange = delta;
            synaps.Weight          += delta;
        }
Пример #2
0
        public void CreateNetwork()
        {
            Neurons  = new List <Neuron> [3];
            Synapses = new List <Synaps>();

            // Инициализация выходного слоя
            Neurons[0] = new List <Neuron>();
            for (int i = 0; i < InputsCount; i++)
            {
                Neurons[0].Add(new Neuron(i));
            }

            // Инициализация второго слоя
            Neurons[1] = new List <Neuron>();
            for (int i = 0; i < neuronsCount; i++)
            {
                Neurons[1].Add(new Neuron(i));
            }

            // Инициализация выходного слоя
            Neurons[2] = new List <Neuron>();
            for (int i = 0; i < OutputsCount; i++)
            {
                Neurons[2].Add(new Neuron(i));
            }


            foreach (Neuron neuron1 in Neurons[0])
            {
                foreach (Neuron neuron2 in Neurons[1])
                {
                    Synaps synaps = new Synaps();
                    Synapses.Add(synaps);
                    neuron1.OutputSynapses.Add(synaps);
                    neuron2.InputSynapses.Add(synaps);
                    synaps.FirstNeuron = neuron1;
                    synaps.LastNeuron  = neuron2;
                }
            }

            foreach (Neuron neuron2 in Neurons[1])
            {
                foreach (Neuron neuron3 in Neurons[2])
                {
                    Synaps synaps = new Synaps();
                    Synapses.Add(synaps);
                    neuron2.OutputSynapses.Add(synaps);
                    neuron3.InputSynapses.Add(synaps);
                    synaps.FirstNeuron = neuron2;
                    synaps.LastNeuron  = neuron3;
                }
            }
        }