public override sealed void Iteration()
{
EncogLogging.Log(EncogLogging.LevelInfo,
"Performing SOM Training iteration.");
PreIteration();
// Reset the BMU and begin this iteration.
_bmuUtil.Reset();
var won = new int[_outputNeuronCount];
double leastRepresentedActivation = Double.MaxValue;
IMLData leastRepresented = null;
// Reset the correction matrix for this synapse and iteration.
_correctionMatrix.Clear();
// Determine the BMU foreach each training element.
foreach (IMLDataPair pair in Training)
{
IMLData input = pair.Input;
int bmu = _bmuUtil.CalculateBMU(input);
// If we are to force a winner each time, then track how many
// times each output neuron becomes the BMU (winner).
if (_forceWinner)
{
won[bmu]++;
// Get the "output" from the network for this pattern. This
// gets the activation level of the BMU.
IMLData output = _network.Compute(pair.Input);
// Track which training entry produces the least BMU. This
// pattern is the least represented by the network.
if (output[bmu] < leastRepresentedActivation)
{
leastRepresentedActivation = output[bmu];
leastRepresented = pair.Input;
}
}
Train(bmu, _network.Weights, input);
if (_forceWinner)
{
// force any non-winning neurons to share the burden somewhat\
if (!ForceWinners(_network.Weights, won,
leastRepresented))
{
ApplyCorrection();
}
}
else
{
ApplyCorrection();
}
}
// update the error
Error = _bmuUtil.WorstDistance/100.0d;
PostIteration();
}