added docs
This commit is contained in:
parent
51578177a5
commit
756207e782
@ -15,7 +15,20 @@ macro interrupts(ex)
|
|||||||
end
|
end
|
||||||
|
|
||||||
struct StopException <: Exception 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()
|
function stop()
|
||||||
throw(StopException())
|
throw(StopException())
|
||||||
end
|
end
|
||||||
@ -52,7 +65,6 @@ function train!(loss, data, opt; cb = () -> ())
|
|||||||
@info "Stop condition met"
|
@info "Stop condition met"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
println(ex)
|
|
||||||
rethrow(ex)
|
rethrow(ex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user