Skip to content

Commit be41a43

Browse files
committed
Add ParameterSchedulers.jl to docs
1 parent 15a0ebf commit be41a43

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/src/ecosystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ machine learning and deep learning workflows:
1616
- [Parameters.jl](https://github.com/mauro3/Parameters.jl): types with default field values, keyword constructors and (un-)pack macros
1717
- [ProgressMeters.jl](https://github.com/timholy/ProgressMeter.jl): progress meters for long-running computations
1818
- [TensorBoardLogger.jl](https://github.com/PhilipVinc/TensorBoardLogger.jl): easy peasy logging to [tensorboard](https://www.tensorflow.org/tensorboard) in Julia
19+
- [ParameterSchedulers.jl](https://github.com/darsnack/ParameterSchedulers.jl): standard scheduling policies for machine learning
1920

2021
This tight integration among Julia packages is shown in some of the examples in the [model-zoo](https://github.com/FluxML/model-zoo) repository.

docs/src/training/optimisers.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,33 @@ In this manner it is possible to compose optimisers for some added flexibility.
137137
Flux.Optimise.Optimiser
138138
```
139139

140+
## Scheduling Optimisers
141+
142+
In practice, it is fairly common to schedule the learning rate of an optimiser to obtain faster convergence. There are a variety of popular scheduling policies, and you can find implementations of them in [ParameterSchedulers.jl](https://darsnack.github.io/ParameterSchedulers.jl/dev/README.html). The documentation for ParameterSchedulers.jl provides a more detailed overview of the different scheduling policies, and how to use them with Flux optimizers. Below, we provide a brief snippet illustrating a [cosine annealing](https://arxiv.org/pdf/1608.03983.pdf) schedule with a momentum optimiser.
143+
144+
First, we import ParameterSchedulers.jl and initalize a cosine annealing schedule to varying the learning rate between `1e-4` and `1e-2` every 10 steps. We also create a new [`Momentum`](@ref) optimiser.
145+
```julia
146+
using ParameterSchedulers
147+
148+
schedule = Cos(λ0 = 1e-4, λ1 = 1e-2, period = 10)
149+
opt = Momentum()
150+
```
151+
152+
Next, you can use your schedule directly in a `for`-loop like any iterator:
153+
```julia
154+
for (eta, epoch) in zip(schedule, 1:100)
155+
opt.eta = eta
156+
# your training code here
157+
end
158+
```
159+
160+
Alternatively, use `ScheduledOptim` from ParameterSchedulers.jl to wrap the optimiser and schedule into a single object that behaves like any Flux optimiser.
161+
```julia
162+
@epochs 100 Flux.train!(loss, ps, data, ScheduledOptim(schedule, opt))
163+
```
164+
165+
ParameterSchedulers.jl allows for many more scheduling policies including arbitrary functions, looping any function with a given period, or sequences of many schedules. See the ParameterSchedulers.jl documentation for more info.
166+
140167
## Decays
141168

142169
Similar to optimisers, Flux also defines some simple decays that can be used in conjunction with other optimisers, or standalone.

0 commit comments

Comments
 (0)