首页 > 代码库 > neuroph实现感知机 计算xor问题
neuroph实现感知机 计算xor问题
package com.core.perceptron;import java.util.Arrays;import org.neuroph.core.*;import org.neuroph.core.data.*;import org.neuroph.nnet.MultiLayerPerceptron;import org.neuroph.util.TransferFunctionType;public class XORDemo { public static void main(String[] args){ DataSet trainingSet = new DataSet(2, 1); trainingSet.addRow(new DataSetRow(new double[]{0, 0}, new double[] {0})); trainingSet.addRow(new DataSetRow(new double[]{0, 1}, new double[] {1})); trainingSet.addRow(new DataSetRow(new double[]{1, 0}, new double[] {1})); trainingSet.addRow(new DataSetRow(new double[]{1, 1}, new double[] {0})); MultiLayerPerceptron myMLP = new MultiLayerPerceptron(TransferFunctionType.TANH, 2 ,3 ,1); System.out.println("Training network..."); myMLP.learn(trainingSet); System.out.println("Testing network"); testNeuralNetwork(myMLP, trainingSet); } public static void testNeuralNetwork(NeuralNetwork nnet, DataSet tset) { for (DataSetRow dataRow : tset.getRows()) { nnet.setInput(dataRow.getInput()); nnet.calculate(); double[ ] networkOutput = nnet.getOutput(); System.out.print("Input: " + Arrays.toString(dataRow.getInput()) ); System.out.println(" Output: " + Arrays.toString(networkOutput) ); } } }
导入neuroph-core-2.93.jar neuroph-imgrec-2.93.jar neuroph-ocr-2.93.jar及slf4j
neuroph实现感知机 计算xor问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。