BasicNetwork network1 = NetworkUtil.createXORNetworkUntrained();
BasicNetwork network2 = NetworkUtil.createXORNetworkUntrained();
MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
// train network 1, no continue
Backpropagation rprop1 = new Backpropagation(network1,trainingData,0.4,0.4);
rprop1.iteration();
rprop1.iteration();
rprop1.iteration();
rprop1.iteration();
// train network 2, continue
Backpropagation rprop2 = new Backpropagation(network2,trainingData,0.4,0.4);
rprop2.iteration();
rprop2.iteration();
TrainingContinuation state = rprop2.pause();
rprop2 = new Backpropagation(network2,trainingData,0.4,0.4);
rprop2.resume(state);
rprop2.iteration();
rprop2.iteration();
// verify weights are the same
double[] weights1 = NetworkCODEC.networkToArray(network1);
double[] weights2 = NetworkCODEC.networkToArray(network2);
Assert.assertEquals(rprop1.getError(), rprop2.getError(), 0.01);
Assert.assertEquals(weights1.length, weights2.length);
Assert.assertArrayEquals(weights1, weights2, 0.01);
}