private double Iterate() { ++_epochNumber; double meanSquare = GetMeanSquare(); Log.Information("Epoch {Epoch}, mean square {MeanSquare}.", _epochNumber, meanSquare); _nodes.ForEach(n => n.UpdateWeights(_learningRate, _weights)); EpochFinished?.Invoke(this, new EpochFinishedEventArgs { Weights = _weights.ToList(), Epoch = _epochNumber, MeanSquare = meanSquare }); return(meanSquare); }
public void Start() { EpochFinished?.Invoke(this, new EpochFinishedEventArgs { Weights = _weights.ToList(), Epoch = 0 }); double meanSquare = double.MaxValue; _epochNumber = 0; while (meanSquare > _desiredLms) { ++_epochNumber; double ms = Iterate(); if (Math.Abs(ms - meanSquare) < 1E-14) { EpochFinished?.Invoke(this, new EpochFinishedEventArgs { Weights = _weights.ToList(), Epoch = _epochNumber, Finished = true, MeanSquare = ms }); return; } meanSquare = ms; } }