Skip to content

Commit 6d5e7da

Browse files
bors[bot]darsnack
andauthoredFeb 23, 2021
Merge #1513
1513: Update for latest ParameterSchedulers.jl release r=darsnack a=darsnack Due to some finagling with #1506 and work on Optimisers.jl, I made some changes to the names/API of ParameterSchedulers.jl. This just updates the docs to reflect those names. ### PR Checklist - [ ] ~~Tests are added~~ - [ ] ~~Entry in NEWS.md~~ - [x] Documentation, if applicable - [ ] ~~Final review from `@dhairyagandhi96` (for API changes).~~ Co-authored-by: Kyle Daruwalla <daruwalla@wisc.edu>
2 parents ea41ea6 + f3b5b13 commit 6d5e7da

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎docs/src/training/optimisers.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,22 @@ First, we import ParameterSchedulers.jl and initalize a cosine annealing schedul
145145
```julia
146146
using ParameterSchedulers
147147

148-
schedule = ScheduleIterator(Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10))
149148
opt = Momentum()
150-
```
151-
152-
Next, you can use your schedule directly in a `for`-loop:
153-
```julia
154-
for epoch in 1:100
155-
opt.eta = next!(schedule)
149+
schedule = Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10)
150+
for (eta, epoch) in zip(schedule, 1:100)
151+
opt.eta = eta
156152
# your training code here
157153
end
158154
```
155+
`schedule` can also be indexed (e.g. `schedule(100)`) or iterated like any iterator in Julia.
159156

160-
`schedule` can also be indexed (e.g. `schedule[100]`) or iterated like any iterator in Julia:
157+
ParameterSchedulers.jl schedules are stateless (they don't store their iteration state). If you want a _stateful_ schedule, you can use `ParameterSchedulers.Stateful`:
161158
```julia
162-
for (eta, epoch) in zip(schedule, 1:100)
163-
opt.eta = eta
159+
using ParameterSchedulers: Stateful, next!
160+
161+
schedule = Stateful(Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10))
162+
for epoch in 1:100
163+
opt.eta = next!(schedule)
164164
# your training code here
165165
end
166166
```

0 commit comments

Comments
 (0)