예제 #1
0
 /// <summary>
 /// Remove all connections (to and from this neuron).
 /// </summary>
 public void IsolateNeuron()
 {
     DisconnectToAllNeurons();
     for (int i = _sourceSynapses.Count - 1; i > -1; i--)
     {
         Synapse s = _sourceSynapses[i];
         s.SourceNeuron.DisconnectToNeuron(s);
     }
 }
예제 #2
0
 /// <summary>
 /// Remove a connection from this neuron forward to another neuron.
 /// </summary>
 /// <param name="s">The synapse feeding this neuron.</param>
 public void DisconnectToNeuron(Synapse s)
 {
     _targetSynapses.Remove(s);
     s.TargetNeuron._sourceSynapses.Remove(s);
     if (TargetSynapseRemoved != null)
     {
         TargetSynapseRemoved(this, new SynapseEventArgs(s));
     }
 }
예제 #3
0
        /// <summary>
        /// Connect this neuron forward to another (specified) neuron.
        /// </summary>
        /// <param name="target">The target neuron.</param>
        /// <param name="weight">The weight of the synapse.</param>
        /// <returns>The new connection synapse.</returns>
        public Synapse ConnectToNeuron(Neuron target, double weight)
        {
            Synapse s = new Synapse(_node.BuildSibling(), this, target, weight);

            _targetSynapses.Add(s);
            target._sourceSynapses.Add(s);
            if (TargetSynapseAdded != null)
            {
                TargetSynapseAdded(this, new SynapseEventArgs(s));
            }
            return(s);
        }
예제 #4
0
 /// <summary>
 /// Evaluate the gradient for the current pattern.
 /// </summary>
 protected virtual void EvaluateGradient()
 {
     if (_targetSynapses.Count == 0)          //Output Neuron
     {
         _cDelta = _config.ActivateDerivative(_cActivity, _cOutput) * (_cTrain - _cOutput);
     }
     else             //Input or Hidden Neuron
     {
         _cDelta = 0;
         for (int i = 0; i < _targetSynapses.Count; i++)
         {
             Synapse s = _targetSynapses[i];
             _cDelta += s.CalculateCurrentFlowDifferential();
         }
         _cDelta *= _config.ActivateDerivative(_cActivity, _cOutput);
     }
 }
예제 #5
0
 /// <summary>
 /// Remove all connections from this neuron forward to another (specified) neuron.
 /// </summary>
 /// <param name="source">The neuron feeding this neuron.</param>
 public void DisconnectToNeuron(Neuron source)
 {
     for (int i = 0; i < _targetSynapses.Count; i++)
     {
         Synapse s = _targetSynapses[i];
         if (s.TargetNeuron == source)
         {
             _targetSynapses.Remove(s);
             s.TargetNeuron._sourceSynapses.Remove(s);
             if (TargetSynapseRemoved != null)
             {
                 TargetSynapseRemoved(this, new SynapseEventArgs(s));
             }
             i--;
         }
     }
 }
예제 #6
0
 /// <summary>
 /// Propagate the neuron.
 /// </summary>
 /// <remarks>
 /// To publish the propagated data, you need to call PublishPropagation afterwards.
 /// </remarks>
 public virtual void Propagate()
 {
     if (_sourceSynapses.Count > 0)
     {
         double old = _cActivity;
         _cActivity = 0;
         if (_config.BiasNeuronEnable.Value && _sourceSynapses.Count != 0)
         {
             _cActivity = _config.BiasNeuronOutput.Value * _cBiasNeuronWeight;
         }
         for (int i = 0; i < _sourceSynapses.Count; i++)
         {
             Synapse s = _sourceSynapses[i];
             _cActivity += s.CalculateCurrentFlow();
         }
         if (!_config.QuietModeEnable.Value && _cActivity != old && ActivityChanged != null)
         {
             ActivityChanged(this, new ValueChangedEventArgs(_cActivity, old));
         }
     }
 }
예제 #7
0
 /// <summary>
 /// Remove a connection from this neuron forward to another neuron.
 /// </summary>
 /// <param name="s">The synapse feeding this neuron.</param>
 public void DisconnectToNeuron(Synapse s)
 {
     _targetSynapses.Remove(s);
     s.TargetNeuron._sourceSynapses.Remove(s);
     if(TargetSynapseRemoved != null)
         TargetSynapseRemoved(this,new SynapseEventArgs(s));
 }
예제 #8
0
 /// <summary>
 /// Connect this neuron forward to another (specified) neuron.
 /// </summary>
 /// <param name="target">The target neuron.</param>
 /// <param name="weight">The weight of the synapse.</param>
 /// <returns>The new connection synapse.</returns>
 public Synapse ConnectToNeuron(Neuron target, double weight)
 {
     Synapse s = new Synapse(_node.BuildSibling(), this, target, weight);
     _targetSynapses.Add(s);
     target._sourceSynapses.Add(s);
     if(TargetSynapseAdded != null)
         TargetSynapseAdded(this,new SynapseEventArgs(s));
     return s;
 }
예제 #9
0
 /// <summary>
 /// Instanciate new event arguments.
 /// </summary>
 /// <param name="synapse">The refering synapse.</param>
 public SynapseEventArgs(Synapse synapse)
 {
     this.synapse = synapse;
 }
예제 #10
0
 /// <summary>
 /// Instanciate new event arguments.
 /// </summary>
 /// <param name="synapse">The refering synapse.</param>
 public SynapseEventArgs(Synapse synapse)
 {
     this.synapse = synapse;
 }