Elman网络无法停止

我的Elman网络在训练XOR运算符时无法停止,运行了数百万次迭代。任何帮助都将不胜感激!

package org.encog.example;import org.encog.Encog;import org.encog.engine.network.activation.ActivationSigmoid;import org.encog.ml.train.MLTrain;import org.encog.neural.data.NeuralDataSet;import org.encog.neural.data.basic.BasicNeuralDataSet;import org.encog.neural.networks.BasicNetwork;import org.encog.neural.networks.training.propagation.back.Backpropagation;import org.encog.neural.pattern.ElmanPattern;public class XORRNN {    // 4行,2列    public static double XOR_INPUT[][] = { { 0.0, 0.0 }, { 1.0, 0.0 },            { 0.0, 1.0 }, { 1.0, 1.0 } };    // 4行,1列    public static double XOR_IDEAL[][] = { { 0.0 }, { 1.0 }, { 1.0 }, { 0.0 } };    public static void main(String[] args) {        //创建Elman RNN        ElmanPattern elmanPattern = new ElmanPattern();        elmanPattern.setInputNeurons(2);        elmanPattern.addHiddenLayer(4);        elmanPattern.setOutputNeurons(1);        elmanPattern.setActivationFunction(new ActivationSigmoid());        BasicNetwork network = (BasicNetwork) elmanPattern.generate();        //读取训练数据        NeuralDataSet trainingSet = new BasicNeuralDataSet(XOR_INPUT, XOR_IDEAL);        //设置训练方法        MLTrain train = new Backpropagation(network, trainingSet, 0.000001, 0.0);        //训练        int epoch = 1;        do{            train.iteration();                      System.out.println("迭代次数: " + epoch + ", 误差: " + train.getError());            epoch ++;        }while(train.getError() > 0.01);        //关闭        Encog.getInstance().shutdown();    }}

回答:

如果你要训练的不是时间序列数据,尝试使用前馈神经网络。使用只有4个训练集元素的Elman网络,你不会取得很好的效果。如果你想了解如何为Elman网络构建XOR数据的示例,请查看以下内容:

https://github.com/encog/encog-java-examples/blob/master/src/main/java/org/encog/examples/neural/recurrent/elman/ElmanXOR.java

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注