private bool ForceWinners(ISynapse synapse, int[] won,
INeuralData leastRepresented)
{
double maxActivation = double.MinValue;
int maxActivationNeuron = -1;
INeuralData output = this.network.Compute(leastRepresented);
// Loop over all of the output neurons. Consider any neurons that were
// not the BMU (winner) for any pattern. Track which of these
// non-winning neurons had the highest activation.
for (int outputNeuron = 0; outputNeuron < won.Length; outputNeuron++)
{
// Only consider neurons that did not "win".
if (won[outputNeuron] == 0)
{
if ((maxActivationNeuron == -1)
|| (output.Data[outputNeuron] > maxActivation))
{
maxActivation = output.Data[outputNeuron];
maxActivationNeuron = outputNeuron;
}
}
}
// If a neurons was found that did not activate for any patterns, then
// force it to "win" the least represented pattern.
if (maxActivationNeuron != -1)
{
CopyInputPattern(synapse, maxActivationNeuron, leastRepresented);
return true;
}
else
{
return false;
}
}