public ThresholdAlgorithm getAverageThresholdAlgorithm ( ) { Collection < ThresholdAlgorithm > c = this . allThreadThresholdAlgorithms . values ( ) ; if ( c . isEmpty ( ) ) { return null ; } if ( c . size ( ) == 1 ) { return c . iterator ( ) . next ( ) ; } Iterator < ThresholdAlgorithm > iter = c . iterator ( ) ; ThresholdAlgorithmReducer r = null ; while ( iter . hasNext ( ) ) { ThresholdAlgorithm ta = iter . next ( ) ; if ( r == null ) { r = ta . newReducer ( ) ; } r . add ( ta ) ; } ThresholdAlgorithm ta = r . getFinalResult ( ) ; //Remove the old instances in preparation for use in next epoch, if required thresholdAlgorithm = new ThreadLocal <> ( ) ; allThreadThresholdAlgorithms . clear ( ) ; return ta ; }
This should ONLY be called once all training threads have completed