gpt4 book ai didi

java - 错误空指针 Neuroph doOneLearningIteration

转载 作者:太空宇宙 更新时间:2023-11-04 12:26:44 26 4
gpt4 key购买 nike

我正在使用 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 函数不起作用,因为在它们内部。它没有启动。因此,要运行,我们需要重写或运行 1 epoch,然后执行 doOneLearningIteration。这对我来说是工作。

关于java - 错误空指针 Neuroph doOneLearningIteration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38305367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com