From c11ab4bf81e80f2c53b64601b08fd85b9e4880e6 Mon Sep 17 00:00:00 2001 From: guo-yong-zhi <55872791+guo-yong-zhi@users.noreply.github.com> Date: Tue, 11 Jan 2022 21:17:01 +0800 Subject: [PATCH] callback_pre --- src/fit.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fit.jl b/src/fit.jl index 20d878e..9bd6e8d 100644 --- a/src/fit.jl +++ b/src/fit.jl @@ -446,7 +446,7 @@ end function train!(ts, nepoch::Number=-1, args...; trainer=trainepoch_EM2!, patient::Number=trainer(:patient), optimiser=Momentum(η=1/4), scheduler=lr->lr*√0.5, - callback=x -> x, reposition=i -> true, resource=trainer(inputs=ts), kargs...) + callback=x -> x, callback_pre=x -> x, reposition=i -> true, resource=trainer(inputs=ts), kargs...) reposition_flag = true if reposition isa Function from = reposition @@ -482,6 +482,7 @@ function train!(ts, nepoch::Number=-1, args...; @info "nepoch: $nepoch, " * (reposition_flag ? "patient: $patient" : "reposition off") updated = get(resource, :updated, nothing) while ep < nepoch + callback_pre(ep) nc = trainer(ts, args...; resource..., optimiser=optimiser, unique=false, kargs...) ep += 1 update!(indi_r, nc)