3

我已使用如下encog库中实现一个神经网络,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); 

} 

此输出错误。 但我想测试这与自定义数据,并检查输出的数据是否为

回答

0

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

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

+0

我提出以下数据来训练和测试神经网络,但输出不是恒定的。 公共静态双train_INPUT [] [] = {{0.0,0.0},{ 1.0,0.0},{ 0.0,1.0},{ 1.0,1.0} \t \t \t}; \t public static double tester [] = {1.0,0.0} ;; \t public static double train_IDEAL [] [] = {{0.0}, {1.0}, {1.0}, {0.0}}; – jee1tha

+0

我只是注意到你的循环条件是train.getError()<0.009。不应该是train.getError()> 0.009?我使用2-3-1网络进行测试,并能够降低到0.008的错误。 (见https://gist.github.com/frankibem/94e588cb2d8ccda2af675f9bde3e25fa和这里:https://gist.github.com/frankibem/eeaa066595e6ba791dfc6cea558f92ca –