You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[`Patience`](@ref EarlyStopping.Patience)`(n=5)`| † Stop after `n` consecutive loss increases | yes
106
-
[`Info`](@ref IterationControl.Info)`(f=identity)`| Log to `Info` the value of `f(mach)`, where `mach` is current machine | no
107
-
[`Warn`](@ref IterationControl.Warn)`(predicate; f="")`| Log to `Warn` the value of `f` or `f(mach)`, if `predicate(mach)` holds | no
108
-
[`Error`](@ref IterationControl.Error)`(predicate; f="")`| Log to `Error` the value of `f` or `f(mach)`, if `predicate(mach)` holds and then stop | yes
[`WithNumberDo`](@ref IterationControl.WithNumberDo)`(f=n->@info(n))` | Call `f(n + 1)` where `n` is number of previous calls | yes
111
-
[`WithIterationsDo`](@ref MLJIteration.WithIterationsDo)`(f=i->@info("num iterations: $i"))`| Call `f(i)`, where `i` is total number of iterations | yes
112
-
[`WithLossDo`](@ref IterationControl.WithLossDo)`(f=x->@info("loss: $x"))` | Call `f(loss)` where `loss` is the current loss | yes
113
-
[`WithTrainingLossesDo`](@ref IterationControl.WithTrainingLossesDo)`(f=v->@info(v))` | Call `f(v)` where `v` is the current batch of training losses | yes
114
-
[`Save`](@ref MLJSerialization.Save)`(filename="machine.jlso")`| * Save current machine to `machine1.jlso`, `machine2.jslo`, etc | yes
[`Patience`](@ref EarlyStopping.Patience)`(n=5)` | † Stop after `n` consecutive loss increases | yes
106
+
[`Info`](@ref IterationControl.Info)`(f=identity)` | Log to `Info` the value of `f(mach)`, where `mach` is current machine | no
107
+
[`Warn`](@ref IterationControl.Warn)`(predicate; f="")` | Log to `Warn` the value of `f` or `f(mach)`, if `predicate(mach)` holds | no
108
+
[`Error`](@ref IterationControl.Error)`(predicate; f="")` | Log to `Error` the value of `f` or `f(mach)`, if `predicate(mach)` holds and then stop | yes
[`WithNumberDo`](@ref IterationControl.WithNumberDo)`(f=n->@info(n))`| Call `f(n + 1)` where `n` is the number of complete control cycles so far | yes
111
+
[`WithIterationsDo`](@ref MLJIteration.WithIterationsDo)`(f=i->@info("num iterations: $i"))`| Call `f(i)`, where `i` is total number of iterations | yes
112
+
[`WithLossDo`](@ref IterationControl.WithLossDo)`(f=x->@info("loss: $x"))`| Call `f(loss)` where `loss` is the current loss | yes
113
+
[`WithTrainingLossesDo`](@ref IterationControl.WithTrainingLossesDo)`(f=v->@info(v))`| Call `f(v)` where `v` is the current batch of training losses | yes
114
+
[`Save`](@ref MLJSerialization.Save)`(filename="machine.jlso")`| * Save current machine to `machine1.jlso`, `machine2.jslo`, etc | yes
115
115
116
116
> Table 1. Atomic controls. Some advanced options omitted.
117
117
@@ -130,11 +130,12 @@ specified in the constructor: `Callback`, `WithNumberDo`,
130
130
131
131
There are also three control wrappers to modify a control's behavior:
[`IterationControl.skip`](@ref)`(control, predicate=1)` | Apply `control` every `predicate` applications of the control wrapper (can also be a function; see doc-string)
136
-
[`IterationControl.debug`](@ref)`(control)` | Apply `control` but also log its state to `Info` (irrespective of `verbosity` level)
137
-
[`IterationControl.composite`](@ref)`(controls...)` | Apply each `control` in `controls` in sequence; used internally by IterationControl.jl
[`IterationControl.skip`](@ref)`(control, predicate=1)` | Apply `control` every `predicate` applications of the control wrapper (can also be a function; see doc-string)
136
+
[`IterationControl.louder`](@ref IterationControl.louder)`(control, by=1)` | Increase the verbosity level of `control` by the specified value (negative values lower verbosity)
137
+
[`IterationControl.debug`](@ref)`(control)` | Apply `control` but also log its state to `Info` (irrespective of `verbosity` level)
138
+
[`IterationControl.composite`](@ref)`(controls...)` | Apply each `control` in `controls` in sequence; used internally by IterationControl.jl
138
139
139
140
> Table 2. Wrapped controls
140
141
@@ -245,7 +246,8 @@ one might use `IterateFromList([round(Int, 10^x) for x in range(1, 2,
245
246
length=10)]`.
246
247
247
248
In the code, `wrapper` is an object that wraps the training machine
248
-
(see above).
249
+
(see above). The variable `n` is a counter for control cycles (unused
250
+
in this example).
249
251
250
252
```julia
251
253
@@ -256,14 +258,14 @@ struct IterateFromList
256
258
IterateFromList(v) =new(unique(sort(v)))
257
259
end
258
260
259
-
function IterationControl.update!(control::IterateFromList, wrapper, verbosity)
261
+
function IterationControl.update!(control::IterateFromList, wrapper, verbosity, n)
260
262
Δi = control.list[1]
261
263
verbosity >1&&@info"Training $Δi more iterations. "
262
264
MLJIteration.train!(wrapper, Δi) # trains the training machine
263
265
return (index =2, )
264
266
end
265
267
266
-
function IterationControl.update!(control::IterateFromList, wrapper, verbosity, state)
268
+
function IterationControl.update!(control::IterateFromList, wrapper, verbosity, n, state)
267
269
index = state.positioin_in_list
268
270
Δi = control.list[i] - wrapper.n_iterations
269
271
verbosity >1&&@info"Training $Δi more iterations. "
@@ -339,12 +341,14 @@ only a single control, called `control`, then training proceeds as
339
341
follows:
340
342
341
343
```julia
342
-
state =update!(control, wrapper, verbosity)
344
+
n =1# initialize control cycle counter
345
+
state =update!(control, wrapper, verbosity, n)
343
346
finished =done(control, state)
344
347
345
348
# subsequent training events:
346
349
while!finished
347
-
state =update!(control, wrapper, verbosity, state)
350
+
n +=1
351
+
state =update!(control, wrapper, verbosity, n, state)
348
352
finished =done(control, state)
349
353
end
350
354
@@ -386,14 +390,14 @@ end
386
390
function IterationControl.update!(control::CycleLearningRate,
387
391
wrapper,
388
392
verbosity,
389
-
state = (n =0, learning_rates=nothing))
390
-
n =state.n
393
+
n,
394
+
state= (learning_rates=nothing, ))
391
395
rates = n ==0?one_cycle(control) : state.learning_rates
0 commit comments