diff --git a/src/optimise/train.jl b/src/optimise/train.jl index d29ec123..6687f268 100644 --- a/src/optimise/train.jl +++ b/src/optimise/train.jl @@ -34,3 +34,24 @@ function train!(loss, data, opt; cb = () -> ()) cb() == :stop && break end end + +""" + @epochs N body + +Run `body` `N` times. Mainly useful for quickly doing multiple epochs of +training in a REPL. + +```julia +julia> @epochs 2 println("hello") +INFO: Epoch 1 +hello +INFO: Epoch 2 +hello +``` +""" +macro epochs(n, ex) + :(@progress for i = 1:$(esc(n)) + info("Epoch $i") + $(esc(ex)) + end) +end diff --git a/src/utils.jl b/src/utils.jl index 5f736eca..5b4f1f17 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -153,24 +153,3 @@ function jacobian(m,x) end J' end - -""" - @epochs N body - -Run `body` `N` times. Mainly useful for quickly doing multiple epochs of -training in a REPL. - -```julia -julia> @epochs 2 println("hello") -INFO: Epoch 1 -hello -INFO: Epoch 2 -hello -``` -""" -macro epochs(n, ex) - :(@progress for i = 1:$(esc(n)) - info("Epoch $i") - $(esc(ex)) - end) -end