Encog 神经网络 validation/Testing

Encog Neural network validation/Testing

我已经使用 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);

}

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

我看到您正在关注其中一个持久性示例。要获得某些输入的输出,请使用 "compute" 函数。例如:

    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 用户指南。很有帮助。