/**
* Process training batches.
*/
protected void processBatches() {
int lastLearn = 0;
final ErrorCalculation errorCalc = new ErrorCalculation();
this.visited.clear();
for (final MLDataPair pair : this.training) {
final MLData input = pair.getInput();
final MLData ideal = pair.getIdeal();
final MLData actual = this.network.compute(input);
final double sig = pair.getSignificance();
errorCalc.updateError(actual.getData(), ideal.getData(), sig);
for (int i = 0; i < this.network.getOutputCount(); i++) {
final double diff = (ideal.getData(i) - actual.getData(i))
* sig;
final FreeformNeuron neuron = this.network.getOutputLayer()
.getNeurons().get(i);
calculateOutputDelta(neuron, diff);
calculateNeuronGradient(neuron);
}
// Are we at the end of a batch.
lastLearn++;
if( lastLearn>=this.batchSize ) {
lastLearn = 0;
learn();
}
}
// Handle any remaining data.
if( lastLearn>0 ) {
learn();
}
// Set the overall error.
setError(errorCalc.calculate());
}