From 756207e782d1f56c1defcd0061a268c889e2fd93 Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Mon, 20 Aug 2018 14:20:33 +0530 Subject: [PATCH] added docs --- src/optimise/train.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/optimise/train.jl b/src/optimise/train.jl index 2fc651bf..c84a8191 100644 --- a/src/optimise/train.jl +++ b/src/optimise/train.jl @@ -15,7 +15,20 @@ macro interrupts(ex) end struct StopException <: Exception end +""" + stop() +Call `stop()` in a callback to indicate when a callback condition is met. +This would trigger the train loop to stop and exit. + +```julia +# Example callback: + +cb = function () + accuracy() > 0.9 && stop() +end +``` +""" function stop() throw(StopException()) end @@ -52,7 +65,6 @@ function train!(loss, data, opt; cb = () -> ()) @info "Stop condition met" break else - println(ex) rethrow(ex) end end