BasicNetwork network1 = NetworkUtil.createXORNetworkUntrained();
BasicNetwork network2 = NetworkUtil.createXORNetworkUntrained();
MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
// train network 1, no continue
ResilientPropagation rprop1 = new ResilientPropagation(network1,trainingData);
rprop1.iteration();
rprop1.iteration();
rprop1.iteration();
rprop1.iteration();
// train network 2, continue
ResilientPropagation rprop2 = new ResilientPropagation(network2,trainingData);
rprop2.iteration();
rprop2.iteration();
TrainingContinuation state = rprop2.pause();
rprop2 = new ResilientPropagation(network2,trainingData);
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);
}