Skip to content

Instantly share code, notes, and snippets.

@zaleslaw
Created June 9, 2022 13:02
Show Gist options
  • Save zaleslaw/d14366591bade09eb56018d10f5505ec to your computer and use it in GitHub Desktop.
Save zaleslaw/d14366591bade09eb56018d10f5505ec to your computer and use it in GitHub Desktop.
val earlyStopping = EarlyStopping(
monitor = EpochTrainingEvent::valLossValue,
minDelta = 0.0,
patience = 2,
verbose = true,
mode = EarlyStoppingMode.AUTO,
baseline = 0.1,
restoreBestWeights = false
)
val terminateOnNaN = TerminateOnNaN()
class EvaluateCallback : Callback() {
override fun onTestBatchEnd(batch: Int, batchSize: Int, event: BatchEvent?, logs: History) {
println("Test batch $batch ends with loss ${event!!.lossValue}..")
}
override fun onTestEnd(logs: History) {
println("Train ends with last loss ${logs.lastBatchEvent().lossValue}")
}
}
class PredictCallback : Callback() {
override fun onPredictBatchBegin(batch: Int, batchSize: Int) {
println("Prediction batch $batch begins.")
}
override fun onPredictBatchEnd(batch: Int, batchSize: Int) {
println("Prediction batch $batch ends.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment