Skip to content

Commit

Permalink
Merge #1513
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and darsnack authored Feb 23, 2021
2 parents ea41ea6 + f3b5b13 commit 6d5e7da
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/src/training/optimisers.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,22 @@ First, we import ParameterSchedulers.jl and initalize a cosine annealing schedul
```julia
using ParameterSchedulers

schedule = ScheduleIterator(Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10))
opt = Momentum()
```

Next, you can use your schedule directly in a `for`-loop:
```julia
for epoch in 1:100
opt.eta = next!(schedule)
schedule = Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10)
for (eta, epoch) in zip(schedule, 1:100)
opt.eta = eta
# your training code here
end
```
`schedule` can also be indexed (e.g. `schedule(100)`) or iterated like any iterator in Julia.

`schedule` can also be indexed (e.g. `schedule[100]`) or iterated like any iterator in Julia:
ParameterSchedulers.jl schedules are stateless (they don't store their iteration state). If you want a _stateful_ schedule, you can use `ParameterSchedulers.Stateful`:
```julia
for (eta, epoch) in zip(schedule, 1:100)
opt.eta = eta
using ParameterSchedulers: Stateful, next!

schedule = Stateful(Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10))
for epoch in 1:100
opt.eta = next!(schedule)
# your training code here
end
```
Expand Down

0 comments on commit 6d5e7da

Please sign in to comment.