错误 NullPointer Neuroph doOneLearningIteration
Error NullPointer Neuroph doOneLearningIteration
我正在使用 Neuroph 2.9 框架编写 ANN 代码来预测房价。我想每次 运行 每个时期都得到每个错误(以在图表上显示错误的改进)但这会导致错误。
// create multi layer perceptron
System.out.println("Creating neural network");
MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(
TransferFunctionType.SIGMOID, inputsCount, hiddentsCount1,
outputsCount);
// set learning parameters
MomentumBackpropagation learningRule = new MomentumBackpropagation();
learningRule.setLearningRate(0.3);
learningRule.setMomentum(0.5);
learningRule.setNeuralNetwork(neuralNet);
learningRule.setTrainingSet(TrainSet);
learningRule.doOneLearningIteration(TrainSet);
我明白了:
Exception in thread "main" java.lang.NullPointerException
at org.neuroph.nnet.learning.MomentumBackpropagation.updateNeuronWeights(MomentumBackpropagation.java:72)
at org.neuroph.nnet.learning.BackPropagation.calculateErrorAndUpdateOutputNeurons(BackPropagation.java:83)
at org.neuroph.nnet.learning.BackPropagation.updateNetworkWeights(BackPropagation.java:53)
at org.neuroph.core.learning.SupervisedLearning.learnPattern(SupervisedLearning.java:190)
at org.neuroph.core.learning.SupervisedLearning.doLearningEpoch(SupervisedLearning.java:165)
at org.neuroph.core.learning.IterativeLearning.doOneLearningIteration(IterativeLearning.java:245)
at com.thao.Main.main(Main.java:76)
问题出在我使用时:learningRule.learn(TrainSet);没关系,没有错误出来。文档太糟糕了,无法根据不同的功能选择正确的功能来 运行 我想要的正确的东西。
我发现 doOneLearningIteration 函数不起作用,因为在它们内部。它没有启动。因此,要运行,我们需要override或者运行1个epoch,然后doOneLearningIteration。
这对我有用。
我正在使用 Neuroph 2.9 框架编写 ANN 代码来预测房价。我想每次 运行 每个时期都得到每个错误(以在图表上显示错误的改进)但这会导致错误。
// create multi layer perceptron
System.out.println("Creating neural network");
MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(
TransferFunctionType.SIGMOID, inputsCount, hiddentsCount1,
outputsCount);
// set learning parameters
MomentumBackpropagation learningRule = new MomentumBackpropagation();
learningRule.setLearningRate(0.3);
learningRule.setMomentum(0.5);
learningRule.setNeuralNetwork(neuralNet);
learningRule.setTrainingSet(TrainSet);
learningRule.doOneLearningIteration(TrainSet);
我明白了:
Exception in thread "main" java.lang.NullPointerException
at org.neuroph.nnet.learning.MomentumBackpropagation.updateNeuronWeights(MomentumBackpropagation.java:72)
at org.neuroph.nnet.learning.BackPropagation.calculateErrorAndUpdateOutputNeurons(BackPropagation.java:83)
at org.neuroph.nnet.learning.BackPropagation.updateNetworkWeights(BackPropagation.java:53)
at org.neuroph.core.learning.SupervisedLearning.learnPattern(SupervisedLearning.java:190)
at org.neuroph.core.learning.SupervisedLearning.doLearningEpoch(SupervisedLearning.java:165)
at org.neuroph.core.learning.IterativeLearning.doOneLearningIteration(IterativeLearning.java:245)
at com.thao.Main.main(Main.java:76)
问题出在我使用时:learningRule.learn(TrainSet);没关系,没有错误出来。文档太糟糕了,无法根据不同的功能选择正确的功能来 运行 我想要的正确的东西。
我发现 doOneLearningIteration 函数不起作用,因为在它们内部。它没有启动。因此,要运行,我们需要override或者运行1个epoch,然后doOneLearningIteration。 这对我有用。