home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (BestScoreEpochTerminationCondition.java)

This example Java source code file (BestScoreEpochTerminationCondition.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

bestscoreepochterminationcondition, epochterminationcondition, override, string

The BestScoreEpochTerminationCondition.java Java example source code

package org.deeplearning4j.earlystopping.termination;

/**
 * Created by Sadat Anwar on 3/26/16.
 *
 * 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)
 */
public class BestScoreEpochTerminationCondition  implements EpochTerminationCondition{
    private final double bestExpectedScore;
    private boolean lesserBetter = true;

    public BestScoreEpochTerminationCondition(double bestExpectedScore){
        this.bestExpectedScore = bestExpectedScore;
    }

    public BestScoreEpochTerminationCondition(double bestExpectedScore, boolean lesserBetter){
        this(bestExpectedScore);
        this.lesserBetter = lesserBetter;
    }

    @Override
    public void initialize() {
        /* No OP */
    }

    @Override
    public boolean terminate(int epochNum, double score) {
        if (lesserBetter) {
            return score < bestExpectedScore;
        } else{
            return bestExpectedScore < score;
        }
    }

    @Override
    public String toString(){
        return "BestScoreEpochTerminationCondition("+bestExpectedScore+")";
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java BestScoreEpochTerminationCondition.java source code file:



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.