public static void main(String[] args)
{
MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
BasicNetwork network = EncogUtility.simpleFeedForward(2, 4, 0, 1, false);
ResilientPropagation train = new ResilientPropagation(network, trainingSet);
train.addStrategy(new RequiredImprovementStrategy(5));
System.out.println("Perform initial train.");
EncogUtility.trainToError(train,0.01);
TrainingContinuation cont = train.pause();
System.out.println(Arrays.toString((double[])cont.getContents().get(ResilientPropagation.LAST_GRADIENTS)));
System.out.println(Arrays.toString((double[])cont.getContents().get(ResilientPropagation.UPDATE_VALUES)));
try
{
cont = (TrainingContinuation)SerializeObject.load(new File("resume.ser"));
}
catch(Exception ex)
{
ex.printStackTrace();
}
System.out.println("Now trying a second train, with continue from the first. Should stop after one iteration");
ResilientPropagation train2 = new ResilientPropagation(network, trainingSet);
train2.resume(cont);
EncogUtility.trainToError(train2,0.01);
}