📄 testgenetic.java
字号:
package org.encog.neural.networks.training;import org.encog.neural.data.NeuralDataSet;import org.encog.neural.data.basic.BasicNeuralDataSet;import org.encog.neural.networks.BasicNetwork;import org.encog.neural.networks.XOR;import org.encog.neural.networks.training.genetic.TrainingSetNeuralGeneticAlgorithm;import junit.framework.TestCase;public class TestGenetic extends TestCase { public void testGenetic() throws Throwable { NeuralDataSet trainingData = new BasicNeuralDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL); BasicNetwork network = XOR.createThreeLayerNet(); TrainingSetNeuralGeneticAlgorithm train = new TrainingSetNeuralGeneticAlgorithm(network, true, trainingData,500,0.1,0.25); train.iteration(); double error1 = train.getError(); train.iteration(); network = (BasicNetwork)train.getNetwork(); double error2 = train.getError(); double improve = (error1-error2)/error1; System.out.println(improve); TestCase.assertTrue("Genetic algorithm did not improve.",improve>0.0001); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -