Java Code Examples for org.neuroph.nnet.learning.MomentumBackpropagation#setLearningRate()
The following examples show how to use
org.neuroph.nnet.learning.MomentumBackpropagation#setLearningRate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WineClassificationSample.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() { System.out.println("Creating training set..."); // get path to training set String dataSetFile = "data_sets/wine_classification_data.txt"; int inputsCount = 13; int outputsCount = 3; // create training set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t", false); System.out.println("Creating neural network..."); // create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 22, outputsCount); // attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.2); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(dataSet); System.out.println("Training completed."); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, dataSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("MyNeuralNetWineClassification.nnet"); System.out.println("Done."); }
Example 2
Source File: SingleImageTrainer.java From FakeImageDetection with GNU General Public License v3.0 | 5 votes |
@Override public void doRun() { HashMap<String, BufferedImage> imagesMap = new HashMap<String, BufferedImage>(); String fileName = ""; if (!isReal) { fileName = "real"; } else { fileName = "faked"; } System.out.println("Teaching as " + fileName); imagesMap.put(fileName, image); Map<String, FractionRgbData> imageRgbData = ImageUtilities.getFractionRgbDataForImages(imagesMap); DataSet learningData = ImageRecognitionHelper.createRGBTrainingSet(labels, imageRgbData); MomentumBackpropagation mBackpropagation = (MomentumBackpropagation) nnet.getLearningRule(); mBackpropagation.setLearningRate(learningRate); mBackpropagation.setMaxError(maxError); mBackpropagation.setMomentum(momentum); System.out.println("Network Information\nLabel = " + nnet.getLabel() + "\n Input Neurons = " + nnet.getInputsCount() + "\n Number of layers = " + nnet.getLayersCount() ); mBackpropagation.addListener(this); System.out.println("Starting training......"); nnet.learn(learningData, mBackpropagation); //Mark nnet as dirty. Write on close isDirty = true; }
Example 3
Source File: PredictingPerformanceOfCPUSample.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() { System.out.println("Creating training set..."); String dataSetFile = "data_sets/cpu_data.txt"; int inputsCount = 7; int outputsCount = 1; // create training set from file DataSet dataSet = DataSets.readFromCsv(dataSetFile, inputsCount, outputsCount); // normalize dataset DataSets.normalizeMax(dataSet); System.out.println("Creating neural network..."); // create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 16, outputsCount); // attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.2); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(dataSet); System.out.println("Training completed."); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, dataSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("MyNeuralNetCPU.nnet"); System.out.println("Done."); }
Example 4
Source File: Model.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private MomentumBackpropagation createMomentumBackpropagation(Double maxError, Integer maxIteration, Double learningRate, Double momentum) { MomentumBackpropagation momentumBackpropagation = new MomentumBackpropagation(); momentumBackpropagation.setMaxError(maxError); momentumBackpropagation.setMaxIterations(maxIteration); momentumBackpropagation.setLearningRate(learningRate); momentumBackpropagation.setMomentum(momentum); return momentumBackpropagation; }
Example 5
Source File: DiabetesSample.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() { String dataSetFile = "data_sets/diabetes.txt"; int inputsCount = 8; int outputsCount = 1; // Create data set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, ","); // Creatinig training set (70%) and test set (30%) DataSet[] trainTestSplit = dataSet.split(0.7, 0.3); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; // Normalizing training and test set Normalizer normalizer = new MaxNormalizer(trainingSet); normalizer.normalize(trainingSet); normalizer.normalize(testSet); System.out.println("Creating neural network..."); //Create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 20, 10, outputsCount); //attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); learningRule.setLearningRate(0.6); learningRule.setMaxError(0.07); learningRule.setMaxIterations(100000); System.out.println("Training network..."); //train the network with training set neuralNet.learn(trainingSet); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, testSet); }
Example 6
Source File: AnimalsClassificationSample.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() { System.out.println("Creating training set..."); String dataSetFile = "data_sets/animals_data.txt"; int inputsCount = 20; int outputsCount = 7; // create training set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t", true); System.out.println("Creating neural network..."); // create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 22, outputsCount); // attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.2); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(dataSet); System.out.println("Training completed."); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, dataSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("MyNeuralNetAnimals.nnet"); System.out.println("Done."); }
Example 7
Source File: GlassIdentificationSample.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() { System.out.println("Creating training set..."); String dataSetFile = "data_sets/glass_identification_data.txt"; int inputsCount = 9; int outputsCount = 7; // create training set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t", false); //dataSet.normalize(); System.out.println("Creating neural network..."); // create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 22, outputsCount); // attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(dataSet); System.out.println("Training completed."); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, dataSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("MyNeuralGlassIdentification.nnet"); System.out.println("Done."); }
Example 8
Source File: BreastCancerSample.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() { System.out.println("Creating training and test set from file..."); String dataSetFile = "data_sets/breast_cancer.txt"; int numInputs = 30; int numOutputs = 1; //Create data set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, numInputs, numOutputs, ","); //Creatinig training set (70%) and test set (30%) DataSet[] trainTestSplit = dataSet.split(0.7, 0.3); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; //Normalizing data set Normalizer normalizer = new MaxNormalizer(trainingSet); normalizer.normalize(trainingSet); normalizer.normalize(testSet); //Create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(numInputs, 16, numOutputs); //attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); learningRule.setLearningRate(0.3); learningRule.setMaxError(0.01); learningRule.setMaxIterations(500); System.out.println("Training network..."); //train the network with training set neuralNet.learn(trainingSet); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, testSet); }
Example 9
Source File: WheatSeeds.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() throws InterruptedException, ExecutionException { System.out.println("Creating training set..."); // get path to training set String dataSetFile = "data_sets/seeds.txt"; int inputsCount = 7; int outputsCount = 3; // create training set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t"); dataSet.shuffle(); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 15, 2, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxError(0.01); learningRule.setMaxIterations(1000); String[] classLabels = new String[]{"Cama", "Rosa", "Canadian"}; neuralNet.setOutputLabels(classLabels); KFoldCrossValidation crossVal = new KFoldCrossValidation(neuralNet, dataSet, 10); EvaluationResult totalResult= crossVal.run(); List<FoldResult> cflist= crossVal.getResultsByFolds(); }
Example 10
Source File: WineQuality.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void run() throws InterruptedException, ExecutionException { System.out.println("Creating training set..."); // get path to training set String dataSetFile = "data_sets/wine.txt"; int inputsCount = 11; int outputsCount = 10; // create training set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t", true); Normalizer norm = new MaxNormalizer(dataSet); norm.normalize(dataSet); dataSet.shuffle(); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 20, 15, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxIterations(10); String classLabels[] = new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; neuralNet.setOutputLabels(classLabels); KFoldCrossValidation crossVal = new KFoldCrossValidation(neuralNet, dataSet, 10); EvaluationResult totalResult= crossVal.run(); List<FoldResult> cflist= crossVal.getResultsByFolds(); }
Example 11
Source File: TrainNetwork.java From NeurophFramework with Apache License 2.0 | 5 votes |
public void createNeuralNetwork() { System.out.println("Creating neural network... "); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(config.getInputCount(), config.getFirstHiddenLayerCount(), config.getSecondHiddenLayerCount(), config.getOutputCount()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.setLearningRate(0.01); learningRule.setMaxError(0.1); learningRule.setMaxIterations(1000); System.out.println("Saving neural network to file... "); neuralNet.save(config.getTrainedNetworkFileName()); System.out.println("Neural network successfully saved!"); }
Example 12
Source File: MomentumTraining.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Create instance of learning rule and setup given parameters * * @return returns learning rule with predefined parameters */ @Override public LearningRule setParameters() { MomentumBackpropagation mbp = new MomentumBackpropagation(); mbp.setBatchMode(getSettings().isBatchMode()); mbp.setLearningRate(getSettings().getLearningRate()); mbp.setMaxError(getSettings().getMaxError()); mbp.setMaxIterations(getSettings().getMaxIterations()); mbp.setMomentum(getSettings().getMomentum()); return mbp; }
Example 13
Source File: Banknote.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating training set..."); // get path to training set String trainingSetFileName = "data_sets/databanknote.txt"; int inputsCount = 4; int outputsCount = 1; // create training set from file DataSet dataSet = DataSet.createFromFile(trainingSetFileName, inputsCount, outputsCount, ",", false); DataSet[] trainTestSplit = dataSet.split(0.6, 0.4); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; Normalizer norm = new MaxNormalizer(trainingSet); norm.normalize(trainingSet); norm.normalize(testSet); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(TransferFunctionType.TANH, inputsCount, 1, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(trainingSet); System.out.println("Training completed."); System.out.println("Testing network..."); System.out.println("Network performance on the test set"); evaluate(neuralNet, testSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("nn1.nnet"); System.out.println("Done."); System.out.println(); System.out.println("Network outputs for test set"); testNeuralNetwork(neuralNet, testSet); }
Example 14
Source File: WineQualityClassification.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating training set..."); // get path to training set String dataSetFile = "data_sets/wine.txt"; int inputsCount = 11; int outputsCount = 10; // create training set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t", true); // split data into train and test set DataSet[] trainTestSplit = dataSet.split(0.6, 0.4); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; Normalizer norm = new MaxNormalizer(trainingSet); norm.normalize(trainingSet); norm.normalize(testSet); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 20, 15, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxIterations(5000); System.out.println("Training network..."); // train the network with training set neuralNet.learn(trainingSet); System.out.println("Training completed."); System.out.println("Testing network..."); System.out.println("Network performance on the test set"); evaluate(neuralNet, testSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("nn1.nnet"); System.out.println("Done."); System.out.println(); System.out.println("Network outputs for test set"); testNeuralNetwork(neuralNet, testSet); }
Example 15
Source File: Sonar.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating training set..."); // get path to training set String trainingSetFileName = "data_sets/sonardata.txt"; int inputsCount = 60; int outputsCount = 1; // create training set from file DataSet dataSet = DataSet.createFromFile(trainingSetFileName, inputsCount, outputsCount, ",", false); // split data into train and test set DataSet[] trainTestSplit = dataSet.split(0.6, 0.4); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; // normalize data using max normalization Normalizer norm = new MaxNormalizer(trainingSet); norm.normalize(trainingSet); norm.normalize(testSet); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 15, 10, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(trainingSet); System.out.println("Training completed."); System.out.println("Testing network..."); System.out.println("Network performance on the test set"); evaluate(neuralNet, testSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("nn1.nnet"); System.out.println("Done."); System.out.println(); System.out.println("Network outputs for test set"); testNeuralNetwork(neuralNet, testSet); }
Example 16
Source File: Ionosphere.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating data set..."); String dataSetFile = "data_sets/ml10standard/ionospheredata.txt"; int inputsCount = 34; int outputsCount = 1; // create data set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, ",", false); // split data into training and test set DataSet[] trainTestSplit = dataSet.split(0.6, 0.4); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; // normalize data Normalizer norm = new MaxNormalizer(trainingSet); norm.normalize(trainingSet); norm.normalize(testSet); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 30, 25, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener((event) -> { MomentumBackpropagation bp = (MomentumBackpropagation) event.getSource(); System.out.println(bp.getCurrentIteration() + ". iteration | Total network error: " + bp.getTotalNetworkError()); }); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(trainingSet); System.out.println("Training completed."); System.out.println("Testing network..."); System.out.println("Network performance on the test set"); evaluate(neuralNet, testSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("nn1.nnet"); System.out.println("Done."); }
Example 17
Source File: PimaIndiansDiabetes.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating data set..."); String dataSetFile = "data_sets/ml10standard/pimadata.txt"; int inputsCount = 8; int outputsCount = 1; // create data set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, "\t", false); // split data into training and test set DataSet[] trainTestSplit = dataSet.split(0.6, 0.4); DataSet trainingSet = trainTestSplit[0]; DataSet testSet = trainTestSplit[1]; // normalize training and test set Normalizer norm = new MaxNormalizer(trainingSet); norm.normalize(trainingSet); norm.normalize(testSet); System.out.println("Creating neural network..."); MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(TransferFunctionType.TANH, inputsCount, 15, 5, outputsCount); neuralNet.setLearningRule(new MomentumBackpropagation()); MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener((event) -> { MomentumBackpropagation bp = (MomentumBackpropagation) event.getSource(); System.out.println(bp.getCurrentIteration() + ". iteration | Total network error: " + bp.getTotalNetworkError()); }); // set learning rate and max error learningRule.setLearningRate(0.1); learningRule.setMaxError(0.03); System.out.println("Training network..."); // train the network with training set neuralNet.learn(trainingSet); System.out.println("Training completed."); System.out.println("Testing network..."); System.out.println("Network performance on the test set"); evaluate(neuralNet, testSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("nn1.nnet"); System.out.println("Done."); }
Example 18
Source File: IonosphereSample2.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating training and test set from file..."); String dataSetFile = "data_sets/ionosphere.csv"; int inputsCount = 34; int outputsCount = 1; //Create data set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, ","); dataSet.shuffle(); //Normalizing data set Normalizer normalizer = new MaxNormalizer(dataSet); normalizer.normalize(dataSet); //Creatinig training set (70%) and test set (30%) DataSet[] trainingAndTestSet = dataSet.createTrainingAndTestSubsets(70, 30); DataSet trainingSet = trainingAndTestSet[0]; DataSet testSet = trainingAndTestSet[1]; // ovde ubaci u petlju sa hidden neuronima i learning rates System.out.println("Creating neural network..."); //Create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 10, 8, outputsCount); //attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); learningRule.setLearningRate(0.4); learningRule.setMaxError(0.01); learningRule.setMaxIterations(10000); System.out.println("Training network..."); //train the network with training set neuralNet.learn(trainingSet); // System.out.println("Testing network...\n\n"); // testNeuralNetwork(neuralNet, testSet); System.out.println("Done."); System.out.println("**************************************************"); // } }
Example 19
Source File: IonosphereSample.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void run() { System.out.println("Creating training and test set from file..."); String dataSetFile = "data_sets/ionosphere.csv"; int inputsCount = 34; int outputsCount = 1; //Create data set from file DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, ","); dataSet.shuffle(); //Normalizing data set Normalizer normalizer = new MaxNormalizer(dataSet); normalizer.normalize(dataSet); //Creatinig training set (70%) and test set (30%) DataSet[] trainingAndTestSet = dataSet.createTrainingAndTestSubsets(70, 30); DataSet trainingSet = trainingAndTestSet[0]; DataSet testSet = trainingAndTestSet[1]; // for (int i = 0; i < 21; i++) { System.out.println("Creating neural network..."); //Create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 16, 8, outputsCount); // System.out.println("HIDDEN COUNT: " + i); //attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); learningRule.setLearningRate(0.2); learningRule.setMaxError(0.01); learningRule.setMaxIterations(10000); System.out.println("Training network..."); //train the network with training set neuralNet.learn(trainingSet); System.out.println("Testing network...\n\n"); testNeuralNetwork(neuralNet, testSet); System.out.println("Done."); System.out.println("**************************************************"); // } }
Example 20
Source File: LensesClassificationSample.java From NeurophFramework with Apache License 2.0 | 3 votes |
public void run() { System.out.println("Creating training set..."); String dataSetFile = "data_sets/lenses_data.txt"; int inputsCount = 9; int outputsCount = 3; System.out.println("Creating training set..."); DataSet dataSet = DataSet.createFromFile(dataSetFile, inputsCount, outputsCount, " ", false); System.out.println("Creating neural network..."); // create MultiLayerPerceptron neural network MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(inputsCount, 16, outputsCount); // attach listener to learning rule MomentumBackpropagation learningRule = (MomentumBackpropagation) neuralNet.getLearningRule(); learningRule.addListener(this); // set learning rate and max error learningRule.setLearningRate(0.2); learningRule.setMaxError(0.01); System.out.println("Training network..."); // train the network with training set neuralNet.learn(dataSet); System.out.println("Training completed."); System.out.println("Testing network..."); testNeuralNetwork(neuralNet, dataSet); System.out.println("Saving network"); // save neural network to file neuralNet.save("MyNeuralNetLenses.nnet"); System.out.println("Done."); }