@@ -0,0 +1,1311 @@
+package org.deeplearning4j.earlystopping.termination;%0A%0A/**%0A * Created by Sadat Anwar on 3/26/16.%0A *%0A * Stop the training once we achieved an expected score. Normally this will stop if the current score is lower than%0A * the initialized score. If you want to stop the training once the score increases the defined score set the%0A * lesserBetter flag to false (feel free to give the flag a better name)%0A */%0Apublic class BestScoreEpochTerminationCondition  implements EpochTerminationCondition%7B%0A    private final double bestExpectedScore;%0A    private boolean lesserBetter = true;%0A%0A    public BestScoreEpochTerminationCondition(double bestExpectedScore)%7B%0A        this.bestExpectedScore = bestExpectedScore;%0A    %7D%0A%0A    public BestScoreEpochTerminationCondition(double bestExpectedScore, boolean lesserBetter)%7B%0A        this(bestExpectedScore);%0A        this.lesserBetter = lesserBetter;%0A    %7D%0A%0A    @Override%0A    public void initialize() %7B%0A        /* No OP */%0A    %7D%0A%0A    @Override%0A    public boolean terminate(int epochNum, double score) %7B%0A        if (lesserBetter) %7B%0A            return score %3C bestExpectedScore;%0A        %7D else%7B%0A            return bestExpectedScore %3C score;%0A        %7D%0A    %7D%0A%0A    @Override%0A    public String toString()%7B%0A        return %22BestScoreEpochTerminationCondition(%22+bestExpectedScore+%22)%22;%0A    %7D%0A%7D%0A

Stop the training once we achieved an expected score. Normally this will stop if the current score is lower than the initialized score. If you want to stop the training once the score increases the defined score set the lesserBetter flag to false (feel free to give the flag a better name). Useful specially in debugging cases when you dont want to finish the training. Also can be used in cases where you are okay with a certain level of error.