encog3 java中的解析csv文件中的异常错误

时间:2017-05-12 11:02:53

标签: java csv networking encog

我正在尝试通过encog3 java库训练神经网络,我使用backpropogation算法,我的数据集是KDD Cup 1999数据集10%(提供完整的源代码 实施和测试入侵检测系统。这个 数据库包含22种不同的攻击和正常连接数据集) 这是我的一些代码:

      public static void main(String[] args) {
      BasicNetwork network = new BasicNetwork(); 
      network.addLayer(new BasicLayer(new ActivationSigmoid(),true,2)); 
      network.addLayer(new BasicLayer(new ActivationSigmoid(),true,3)); 
      network.addLayer(new BasicLayer(new ActivationSigmoid(),true,1)); 
      //network.setLogic(new FeedforwardLogic()); 
      network.getStructure().finalizeStructure();  
      network.reset();
    // create training data
       MLDataSet trainingSet = new CSVNeuralDataSet("kddcupupdate.csv", 2, 1, true);
       File f =new File("mytrainset");
       EncogUtility.saveEGB(f, trainingSet);
      // train the neural n
       final Backpropagation train = new Backpropagation(network, trainingSet, 0.7, 0.3);

        int epoch = 1;
          do { 
           train.iteration(); 
           System.out
             .println("Epoch #" + epoch + " Error:" + train.getError()); 
           epoch++; 
          } while(train.getError() > 0.01); 

          // test the neural network 
          System.out.println("Neural Network Results:"); 
          for(MLDataPair pair: trainingSet ) { 
           final MLData output = network.compute(pair.getInput()); 
           System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1) 
             + ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0)); 
          } 

}

当我运行此代码时,给出异常错误:

Exception in thread "main" org.encog.util.csv.CSVError: Error:Unparseable number: "tcp" on [tcp], decimal:.,sep: ,
at org.encog.util.csv.CSVFormat.parse(CSVFormat.java:191)
at org.encog.util.csv.ReadCSV.getDouble(ReadCSV.java:312)
at org.encog.ml.data.buffer.codec.CSVDataCODEC.read(CSVDataCODEC.java:215)
at org.encog.ml.data.buffer.MemoryDataLoader.external2Memory(MemoryDataLoader.java:89)
at org.encog.ml.data.specific.CSVNeuralDataSet.<init>(CSVNeuralDataSet.java:111)
at org.encog.ml.data.specific.CSVNeuralDataSet.<init>(CSVNeuralDataSet.java:77)

0 个答案:

没有答案