From 5153cde847b7e99b16605eb0a0136d2a2edfe4c9 Mon Sep 17 00:00:00 2001 From: Mike Innes Date: Mon, 5 Mar 2018 22:56:22 +0000 Subject: [PATCH] move epochs --- src/optimise/train.jl | 21 +++++++++++++++++++++ src/utils.jl | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) 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