示例#1
0
        private void UpdatedWeightPlus(double[] neuronPreviousWeightDerivatives, double[] neuronWeightDerivatives,
                                       double[] neuronWeightUpdates, NeuronRProp neuron, int index)
        {
            int change = Sign(neuronPreviousWeightDerivatives[index] * neuronWeightDerivatives[index]);

            if (change > 0)
            {
                double delta = neuronWeightUpdates[index] * EtaPlus;
                delta = Math.Min(delta, DeltaMax);
                neuronWeightUpdates[index]             = delta;
                neuron.Weights[index]                 -= Sign(neuronWeightDerivatives[index]) * delta;
                neuronPreviousWeightDerivatives[index] = neuronWeightDerivatives[index];
            }
            else if (change < 0)
            {
                double delta = neuronWeightUpdates[index] * EtaMinus;
                delta = Math.Max(delta, DeltaMin);
                neuronWeightUpdates[index]             = delta;
                neuronPreviousWeightDerivatives[index] = 0;
            }
            else if (change == 0)
            {
                double delta = neuronWeightUpdates[index];
                neuron.Weights[index] -= Sign(neuronWeightDerivatives[index]) * delta;
                neuronPreviousWeightDerivatives[index] = neuronWeightDerivatives[index];
            }
        }
示例#2
0
        private void UpdateThresholdPlus(double[] layerPreviousThresholdDerivatives, double[] layerThresholdDerivatives,
                                         double[] layerThresholdUpdates, NeuronRProp neuron, int index)
        {
            int change = Sign(layerPreviousThresholdDerivatives[index] * layerThresholdDerivatives[index]);

            if (change > 0)
            {
                layerThresholdUpdates[index]             = Math.Min(layerThresholdUpdates[index] * EtaPlus, DeltaMax);
                neuron.Threshold                        -= Sign(layerThresholdDerivatives[index]) * layerThresholdUpdates[index];
                layerPreviousThresholdDerivatives[index] = layerThresholdDerivatives[index];
            }
            else if (change < 0)
            {
                layerThresholdUpdates[index]     = Math.Max(layerThresholdUpdates[index] * EtaMinus, DeltaMin);
                layerThresholdDerivatives[index] = 0;
            }
            else if (change == 0)
            {
                neuron.Threshold -= Sign(layerThresholdDerivatives[index]) * layerThresholdUpdates[index];
                layerPreviousThresholdDerivatives[index] = layerThresholdDerivatives[index];
            }
        }