错误NullPointer Neuroph doOneLearningIteration

时间:2016-07-11 11:06:31

标签: java neural-network backpropagation

我正在使用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);没关系,没有错误出来。文档差异很大,不同的功能选择正确的功能来运行我想要的正确的东西。

1 个答案:

答案 0 :(得分:0)

我发现的事情是doOneLearningIteration函数不起作用,因为在它们内部。它没有发起。因此,要运行,我们需要覆盖或运行1个纪元,然后运行doOneLearningIteration。 这对我有用。