handle epoch elsewhere

This commit is contained in:
Mike J Innes 2017-09-07 00:29:55 -04:00
parent aeaa138b6d
commit 085d3aa9b4

View File

@ -4,14 +4,11 @@ using Flux.Tracker: back!
tocb(f) = f tocb(f) = f
tocb(fs::AbstractVector) = () -> foreach(call, fs) tocb(fs::AbstractVector) = () -> foreach(call, fs)
function train!(m, data, opt; epoch = 1, cb = () -> ()) function train!(m, data, opt; cb = () -> ())
cb = tocb(cb) cb = tocb(cb)
@progress for e in 1:epoch @progress for (x, y) in data
epoch > 1 && info("Epoch $e") back!(m(x, y))
@progress for (x, y) in data opt()
back!(m(x, y)) cb()
opt()
cb()
end
end end
end end