Skip to content

Commit 6c747f3

Browse files
mcabbottToucheSir
andauthored
mark stop, skip, @epochs as deprecated (FluxML#2027)
* mark stop, skip, at-epochs as deprecated * remove at-epochs from testing * add removal notes * typo * Apply suggestions from code review Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com> Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
1 parent bc7b54c commit 6c747f3

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/optimise/train.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ struct SkipException <: Exception end
3838
Call `Flux.skip()` in a callback to indicate when a callback condition is met.
3939
This will trigger the train loop to skip the current data point and not update with the calculated gradient.
4040
41+
!!! note
42+
`Flux.skip()` will be removed from Flux 0.14
43+
4144
# Examples
4245
```julia
4346
cb = function ()
@@ -46,6 +49,8 @@ end
4649
```
4750
"""
4851
function skip()
52+
Base.depwarn("""Flux.skip() will be removed from Flux 0.14.
53+
and should be replaced with `continue` in an ordinary `for` loop.""", :skip)
4954
throw(SkipException())
5055
end
5156

@@ -58,6 +63,9 @@ struct StopException <: Exception end
5863
Call `Flux.stop()` in a callback to indicate when a callback condition is met.
5964
This will trigger the train loop to stop and exit.
6065
66+
!!! note
67+
`Flux.stop()` will be removed from Flux 0.14. It should be replaced with `break` in an ordinary `for` loop.
68+
6169
# Examples
6270
```julia
6371
cb = function ()
@@ -66,6 +74,8 @@ end
6674
```
6775
"""
6876
function stop()
77+
Base.depwarn("""Flux.stop() will be removed from Flux 0.14.
78+
It should be replaced with `break` in an ordinary `for` loop.""", :stop)
6979
throw(StopException())
7080
end
7181

@@ -140,8 +150,11 @@ end
140150
Run `body` `N` times. Mainly useful for quickly doing multiple epochs of
141151
training in a REPL.
142152
153+
!!! note
154+
The macro `@epochs` will be removed from Flux 0.14. Please just write an ordinary `for` loop.
155+
143156
# Examples
144-
```jldoctest
157+
```julia
145158
julia> Flux.@epochs 2 println("hello")
146159
[ Info: Epoch 1
147160
hello
@@ -150,6 +163,8 @@ hello
150163
```
151164
"""
152165
macro epochs(n, ex)
166+
Base.depwarn("""The macro `@epochs` will be removed from Flux 0.14.
167+
As an alternative, you can write a simple `for i in 1:epochs` loop.""", Symbol("@epochs"), force=true)
153168
:(@progress for i = 1:$(esc(n))
154169
@info "Epoch $i"
155170
$(esc(ex))

src/utils.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ julia> loss() = rand();
648648
julia> trigger = Flux.patience(() -> loss() < 1, 3);
649649
650650
651-
julia> Flux.@epochs 10 begin
651+
julia> for i in 1:10
652+
@info "Epoch \$i"
652653
trigger() && break
653654
end
654655
[ Info: Epoch 1
@@ -685,7 +686,8 @@ julia> loss = let l = 0
685686
julia> es = Flux.early_stopping(loss, 3);
686687
687688
688-
julia> Flux.@epochs 10 begin
689+
julia> for i in 1:10
690+
@info "Epoch \$i"
689691
es() && break
690692
end
691693
[ Info: Epoch 1
@@ -726,7 +728,8 @@ julia> f = let v = 10
726728
julia> trigger = Flux.plateau(f, 3; init_score=10, min_dist=18);
727729
728730
729-
julia> Flux.@epochs 10 begin
731+
julia> for i in 1:10
732+
@info "Epoch \$i"
730733
trigger() && break
731734
end
732735
[ Info: Epoch 1

0 commit comments

Comments
 (0)