我正在使用 Encog AI 框架使用 HyperNEAT 网络进行时间序列预测。
这是我用来创建网络的简单代码。
Substrate substrate = SubstrateFactory.factorSandwichSubstrate(columns*windowSize,days);
CalculateScore score = new TrainingSetScore(trainingSet);
NEATPopulation pop = new NEATPopulation(substrate, 500);
pop.setActivationCycles(4);
pop.reset();
EvolutionaryAlgorithm train = NEATUtil.constructNEATTrainer(pop, score);
OriginalNEATSpeciation speciation = new OriginalNEATSpeciation();
speciation.setCompatibilityThreshold(1);
train.setSpeciation(speciation = new OriginalNEATSpeciation());
System.out.println("Is HyperNEAT "+pop.isHyperNEAT());
// train the neural network
int epoch = 1;
do {
train.iteration();
if(writeOnStdOut)
System.out.println("Epoch #" + epoch + " Error:" + train.getError());
epoch++;
if(Math.abs(train.getError()-previousError)<0.000000001) iterationWithoutImprovement++; else iterationWithoutImprovement = 0;
previousError = train.getError();
Date dtemp = new Date();
} while(train.getError() > maximumAcceptedErrorTreshold && epoch < maxIterations && iterationWithoutImprovement < maxiter);
NEATGenome genome = (NEATGenome) pop.getBestGenome();
HyperNEATCODEC codec = new HyperNEATCODEC();
network2 = (NEATNetwork) codec.decode(pop, substrate, genome);
其中 columns 是特征的数量,windowSize 是预测未来值所需的前几天数(在我的示例中 windowSize 为 1)。
我得到这个例外:
Exception in thread "pool-2-thread-416" java.lang.ArrayIndexOutOfBoundsException
at org.encog.util.EngineArray.arrayCopy(EngineArray.java:107)
at org.encog.neural.neat.NEATNetwork.compute(NEATNetwork.java:194)
at org.encog.util.error.CalculateRegressionError.calculateError(CalculateRegressionError.java:46)
at org.encog.neural.networks.training.TrainingSetScore.calculateScore(TrainingSetScore.java:61)
at org.encog.ml.ea.score.parallel.ParallelScoreTask.run(ParallelScoreTask.java:83)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
处理线程似乎有问题。有人可以帮我解决这个问题吗?我的第二个问题是:如何在 Encog 中使用反向传播训练 NEAT 网络?