public void trainAndSave() { System.out.println("Training XOR network to under 1% error rate."); BasicNetwork network = new BasicNetwork(); network.addLayer(new BasicLayer(2)); network.addLayer(new BasicLayer(2)); network.addLayer(new BasicLayer(1)); network.getStructure().finalizeStructure(); network.reset(); NeuralDataSet trainingSet = new BasicNeuralDataSet(XOR_INPUT, XOR_IDEAL); // train the neural network final Train train = new ResilientPropagation(network, trainingSet); do { train.iteration(); } while (train.getError() > 0.009); double e = network.calculateError(trainingSet); System.out.println("Network traiined to error: " + e); System.out.println("Saving network"); final EncogPersistedCollection encog = new EncogPersistedCollection(FILENAME); encog.create(); encog.add("network", network); }