Skip to content

Commit

Permalink
Merge pull request #36 from ablaom/dev
Browse files Browse the repository at this point in the history
For a 0.3.1 release
  • Loading branch information
ablaom authored Mar 29, 2021
2 parents 43577d2 + 5456bd5 commit 0466c41
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "IterationControl"
uuid = "b3c1a2ee-3fec-4384-bf48-272ea71de57c"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "0.3.0"
version = "0.3.1"

[deps]
EarlyStopping = "792122b4-ca99-40de-a6bc-6742525f08b6"
Expand Down
2 changes: 1 addition & 1 deletion src/controls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Step(; n=5) = Step(n)

function update!(c::Step, model, verbosity, args...)
if verbosity > 1
@info "Steping model for $(c.n) iterations. "
@info "Stepping model for $(c.n) iterations. "
else
nothing
end
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function detailed_doc_string(M; header="", example="", body="")
ret = " $header"
ret *= "\n\n"
ret *= "An iteration control, as in `$example`. "
ret *= "An iteration control, as in, `$example`. "
ret *= "\n\n"
ret *= body
return ret
Expand Down
32 changes: 16 additions & 16 deletions test/controls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ end
@test IC.takedown(c, 0, state) == (done = false, log="")

v = Float64[]
f(model) = (push!(v, IC.loss(model)); last(v) < 0.02)
f2(model) = (push!(v, IC.loss(model)); last(v) < 0.02)

c = Callback(f, stop_if_true=true)
c = Callback(f2, stop_if_true=true)
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand All @@ -149,9 +149,9 @@ end
log="Stop triggered by a `Callback` control. ")

v = Float64[]
f(model) = (push!(v, IC.loss(model)); last(v) < 0.02)
f3(model) = (push!(v, IC.loss(model)); last(v) < 0.02)

c = Callback(f, stop_if_true=true, stop_message="foo")
c = Callback(f3, stop_if_true=true, stop_message="foo")
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand Down Expand Up @@ -184,8 +184,8 @@ end
@test IC.takedown(c, 0, state) == (done = false, log="")

v = Float64[]
f(loss) = (push!(v, loss); last(v) < 0.02)
c = WithLossDo(f, stop_if_true=true)
f2(loss) = (push!(v, loss); last(v) < 0.02)
c = WithLossDo(f2, stop_if_true=true)
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand All @@ -200,8 +200,8 @@ end
log="Stop triggered by a `WithLossDo` control. ")

v = Float64[]
f(loss) = (push!(v, loss); last(v) < 0.02)
c = WithLossDo(f, stop_if_true=true, stop_message="foo")
f3(loss) = (push!(v, loss); last(v) < 0.02)
c = WithLossDo(f3, stop_if_true=true, stop_message="foo")
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand Down Expand Up @@ -234,8 +234,8 @@ end
@test IC.takedown(c, 0, state) == (done = false, log="")

v = Float64[]
f(training_loss) = (push!(v, last(training_loss)); last(v) < 0.5)
c = WithTrainingLossesDo(f, stop_if_true=true)
f1(training_loss) = (push!(v, last(training_loss)); last(v) < 0.5)
c = WithTrainingLossesDo(f1, stop_if_true=true)
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand All @@ -250,8 +250,8 @@ end
log="Stop triggered by a `WithTrainingLossesDo` control. ")

v = Float64[]
f(training_loss) = (push!(v, last(training_loss)); last(v) < 0.5)
c = WithTrainingLossesDo(f, stop_if_true=true, stop_message="foo")
f2(training_loss) = (push!(v, last(training_loss)); last(v) < 0.5)
c = WithTrainingLossesDo(f2, stop_if_true=true, stop_message="foo")
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand Down Expand Up @@ -283,8 +283,8 @@ end
@test IC.takedown(c, 0, state) == (done = false, log="")

v = Int[]
f(n) = (push!(v, n); last(n) > 1)
c = WithNumberDo(f, stop_if_true=true)
f2(n) = (push!(v, n); last(n) > 1)
c = WithNumberDo(f2, stop_if_true=true)
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand All @@ -299,8 +299,8 @@ end
log="Stop triggered by a `WithNumberDo` control. ")

v = Int[]
f(n) = (push!(v, n); last(n) > 1)
c = WithNumberDo(f, stop_if_true=true, stop_message="foo")
f3(n) = (push!(v, n); last(n) > 1)
c = WithNumberDo(f3, stop_if_true=true, stop_message="foo")
m = SquareRooter(4)
IC.train!(m, 1)
state = IC.update!(c, m, 1)
Expand Down
6 changes: 3 additions & 3 deletions test/train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
@test_logs((:info, r"Stop triggered by Num"),
IC.train!(m, Step(2), NotANumber(), NumberLimit(3)));
@test_logs((:info, r"Using these controls"),
(:info, r"Steping model for 2 iterations"),
(:info, r"Steping model for 2 iterations"),
(:info, r"Steping model for 2 iterations"),
(:info, r"Stepping model for 2 iterations"),
(:info, r"Stepping model for 2 iterations"),
(:info, r"Stepping model for 2 iterations"),
(:info, r"Stop triggered by NumberLimit"),
IC.train!(m, Step(2),
NotANumber(),
Expand Down

0 comments on commit 0466c41

Please sign in to comment.