julia> f(x) = true
f (generic function with 1 method)
julia> WithTrainingLossesDo(f)
WithTrainingLossesDo{typeof(f)}(f, false, nothing)
julia> WithTrainingLossesDo(f=f)
WithTrainingLossesDo{typeof(f)}(f, false, nothing)
julia> WithTrainingLossesDo(f=f, stop_if_true=true)
ERROR: MethodError: no method matching WithTrainingLossesDo(::typeof(f), ::Pair{Symbol, Bool})
Closest candidates are:
WithTrainingLossesDo(::Function; stop_if_true, stop_message) at /Users/anthony/.julia/packages/IterationControl/lO4bA/src/controls.jl:335
WithTrainingLossesDo(::F, ::Bool, ::Union{Nothing, String}) where F<:Function at /Users/anthony/.julia/packages/IterationControl/lO4bA/src/controls.jl:327
Stacktrace:
[1] WithTrainingLossesDo(; f::Function, kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:stop_if_true,), Tuple{Bool}}})
@ IterationControl ~/.julia/packages/IterationControl/lO4bA/src/controls.jl:336
[2] top-level scope
@ REPL[119]:1
[3] top-level scope
@ ~/.julia/packages/CUDA/nYggH/src/initialization.jl:52
According to doc-string:
WithTrainingLossesDo(f=v->@info("training: $v"), stop_if_true=false, stop_message=nothing)
An iteration control, as in, WithTrainingLossesDo(v->put!(my_losses, last(v)).
Call f(training_losses), where training_losses is the vector of most recent batch of
training losses.
If stop_if_true is true, then trigger an early stop if the value returned by f is true,
logging the stop_message if specified.
According to doc-string: