Example #1
0
        public Synapse(Neuron n1, Neuron n2)
        {
            _from = n1;
            _to = n2;

            int sign = (0 == _random.Next() % 2 ? -1 : 1);

            Weight = sign * _random.NextDouble() ;

            //Weight = sign * _random.NextDouble() / 2.0;
        }
Example #2
0
        private void PaintNeuron(Neuron neuron, Graphics g, int top, int left)
        {
            _neuralPosition.Add(neuron, new Point(left, top));

            Brush brush = _neuralBrush;

            if (neuron is TresholdNeuron)
            {
                brush = _treshHoldNeuralBrush;
            }

            if (neuron is OutputNeuron)
            {
                var n = neuron as OutputNeuron;
                brush = n.DesiredValue < 1.0 ? _outputNeuralBrush : _outputHighBruh;
                g.FillEllipse(brush, left, top, 15, 15);
                g.DrawString(n.ToString(), _fontForNeuralValue, brush, (float)left + 10, (float)top + 20);
            }

            else
            {
                g.FillEllipse(brush, left, top, 15, 15);
                g.DrawString(neuron.ToString(), _fontForNeuralValue, _neuralValueBrush, (float)left + 10, (float)top + 20);
            }

            // g.DrawString(neuron.Index.ToString(), _font, _neuralBrush, (float)left + 10, (float)top + 32);
        }
Example #3
0
 protected virtual void AddSingleNeuron(Neuron neuron)
 {
     _neurons.Add(neuron);
 }
Example #4
0
 public void AdjustSynapticWeights(Neuron targetNeuron, double error, double learningFactor)
 {
     double momentum = 0.0;
     foreach (var neuron in _neurons)
     {
         foreach (var synapse in neuron.Synapses)
         {
             if (synapse.Neuron2 == targetNeuron)
             {
                 double delta = learningFactor * error * synapse.Neuron1.Value;
                 synapse.Weight = synapse.Weight + delta + momentum * synapse.DeltaWeight;
             }
         }
     }
 }
Example #5
0
 internal Synapse(Neuron n1, Neuron n2, double weight)
 {
     _from = n1;
     _to = n2;
     Weight = weight;
 }