public static double trainNetwork(final String what,
final BasicNetwork network, final MLDataSet trainingSet) {
// train the neural network
CalculateScore score = new TrainingSetScore(trainingSet);
final MLTrain trainAlt = new NeuralSimulatedAnnealing(
network, score, 10, 2, 100);
final MLTrain trainMain = new Backpropagation(network, trainingSet,0.000001, 0.0);
((Propagation)trainMain).setNumThreads(1);
final StopTrainingStrategy stop = new StopTrainingStrategy();
trainMain.addStrategy(new Greedy());
trainMain.addStrategy(new HybridStrategy(trainAlt));
trainMain.addStrategy(stop);
int epoch = 0;
while (!stop.shouldStop()) {
trainMain.iteration();
System.out.println("Training " + what + ", Epoch #" + epoch
+ " Error:" + trainMain.getError());
epoch++;
}
return trainMain.getError();
}