/** * Whether to terminate or not * * @param epoch the current epoch * @return whether to terminate or not on the given epoch */ @Override public boolean shouldStop(int epoch) { if (!(epoch % validationEpochs == 0) || epoch < 2) return false; double score = network.score(); if (score < bestLoss) { if (score < bestLoss * improvementThreshold) { bestLoss = score; patience = Math.max(patience, epoch * patienceIncrease); } } boolean ret = patience < epoch; if (ret) { log.info("Returning early on finetune"); } return ret; }