Esempio n. 1
0
        /// <summary>
        /// Train this synapse.
        /// </summary>
        public void OptimizeWeights()
        {
            double buffer = _weight;

            if (_config.WeightDecayEnable.Value)
            {
                _weight -= _weight * _config.WeightDecay.Value;
            }
            if (_config.MomentumTermEnable.Value)
            {
                _weight += _weightBuffer * _config.MomentumTerm.Value;
            }
            _weightBuffer = buffer;
            if (_config.ManhattanTrainingEnable.Value)
            {
                _weight += _config.LearningRate.Value * _sourceNeuron.CurrentOutput * Math.Sign(_targetNeuron.CurrentDelta);
            }
            else
            {
                _weight += _config.LearningRate.Value * _sourceNeuron.CurrentOutput * _targetNeuron.CurrentDelta;
            }
            _weight += _config.PreventWeightSymmetrySummand();
            if (WeightChanged != null && !_config.QuietModeEnable.Value && buffer != _weight)
            {
                WeightChanged(this, new ValueChangedEventArgs(_weight, buffer));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Optimize the weights based on the published gradient data.
 /// </summary>
 public void OptimizeWeights()
 {
     for (int i = 0; i < _sourceSynapses.Count; i++)
     {
         (_sourceSynapses[i]).OptimizeWeights();
     }
     if (_config.BiasNeuronEnable.Value)
     {
         double buffer = _cBiasNeuronWeight;
         if (_config.WeightDecayEnable.Value)
         {
             _cBiasNeuronWeight -= _cBiasNeuronWeight * _config.WeightDecay.Value;
         }
         if (_config.ManhattanTrainingEnable.Value)
         {
             _cBiasNeuronWeight += _config.LearningRate.Value * _config.BiasNeuronOutput.Value * Math.Sign(_cDelta);
         }
         else
         {
             _cBiasNeuronWeight += _config.LearningRate.Value * _config.BiasNeuronOutput.Value * _cDelta;
         }
         _cBiasNeuronWeight += _config.PreventWeightSymmetrySummand();
     }
 }