trainingSet.addElement(new SupervisedTrainingElement(new double[]{0, 1}, new double[]{0}));
trainingSet.addElement(new SupervisedTrainingElement(new double[]{1, 0}, new double[]{0}));
trainingSet.addElement(new SupervisedTrainingElement(new double[]{1, 1}, new double[]{1}));
// create perceptron neural network
NeuralNetwork myPerceptron = new Perceptron(2, 1);
// learn the training set
myPerceptron.learnInSameThread(trainingSet);
// test perceptron
System.out.println("Testing trained perceptron");
testNeuralNetwork(myPerceptron, trainingSet);
// save trained perceptron
myPerceptron.save("mySamplePerceptron.nnet");
// load saved neural network
NeuralNetwork loadedPerceptron = NeuralNetwork.load("mySamplePerceptron.nnet");
// test loaded neural network
System.out.println("Testing loaded perceptron");
testNeuralNetwork(loadedPerceptron, trainingSet);