Search code examples
javaneural-networkencog

How to get only last actual output


My data consists of 3 inputs variables (double), and 1 output. I am training with around 20,000- 50,000 rows of data. This code show me every input,actual output and ideal output.

for(MLDataPair pair: trainingSet ) {
        final MLData output = network.compute(pair.getInput());
        System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1)+","+pair.getInput().getData(2)
                + ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
    }

I would like to get only last actual output. Only one last value. How to write this code? Can somebody write it to me please.


Solution

  •     int i = 0;
        for(MLDataPair pair: trainingSet ) {
        i++;
        final MLData output = network.compute(pair.getInput());
        if(i == trainingSet.size()-1){
             System.out.println("actual=" + output.getData(0));
           }
        }