gpt4 book ai didi

java - Encog 神经网络验证/测试

转载 作者:行者123 更新时间:2023-12-02 09:14:23 25 4
gpt4 key购买 nike

我已经使用 encog 库实现了一个神经网络,如下所示,

MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);

final Propagation train = new Backpropagation(network, trainingSet);
int epoch = 1;
do {
train.iteration();
System.out.println("Epoch #" + epoch +
" Error:" + train.getError());
epoch++;

} while (train.getError() < 0.009);

double e = network.calculateError(trainingSet);
System.out.println("Network trained to error :" + e);
System.out.println("Saving Network");


EncogDirectoryPersistence.saveObject(new File(FILENAME), network);
}


public void loadAndEvaluate(){
System.out.println("Loading Network");
BasicNetwork network = (BasicNetwork) EncogDirectoryPersistence.loadObject(new File(FILENAME));

BasicMLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT,XOR_IDEAL);

double e = network.calculateError(trainingSet);

System.out.println("Loaded network's error is (should be the same as above ):" + e);

}

这会输出错误。但我想用自定义数据对此进行测试,并检查一组数据给出的输出是否为

最佳答案

我发现您正在遵循持久性示例之一。要获得某些输入的输出,请使用“计算”​​功能。举个例子:

    double[] output = new double[1];
network.compute(new double[]{1.0, 1.0}, output);
System.out.println("Network output: " + output[0] + " (should be close to 0.0)");

Here's java 用户指南。这很有帮助。

关于java - Encog 神经网络验证/测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38992681/

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