@ Override public int predict ( double [ ] x , double [ ] y ) { setInput ( x ) ; propagate ( ) ; getOutput ( y ) ; if ( outputLayer . units == 1 ) { if ( outputLayer . output [ 0 ] > 0.5 ) { return 0 ; } else { return 1 ; } } double max = Double . NEGATIVE_INFINITY ; int label = - 1 ; for ( int i = 0 ; i < outputLayer . units ; i ++ ) { if ( outputLayer . output [ i ] > max ) { max = outputLayer . output [ i ] ; label = i ; } } return label ; }
Predict the target value of a given instance . Note that this method is NOT multi - thread safe .