From 32e0aa9fcb2812b1aca279d5466a2d3c8a6264f4 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Sun, 1 Mar 2020 15:15:39 +0100 Subject: [PATCH 1/3] docstring ensure signature code formatting by using a four space indent instead of two --- src/data/dataloader.jl | 2 +- src/data/iris.jl | 2 -- src/optimise/optimisers.jl | 8 ++++---- src/optimise/train.jl | 4 ++-- src/utils.jl | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/data/dataloader.jl b/src/data/dataloader.jl index baf32a83..8868a9b0 100644 --- a/src/data/dataloader.jl +++ b/src/data/dataloader.jl @@ -11,7 +11,7 @@ struct DataLoader end """ - DataLoader(data...; batchsize=1, shuffle=false, partial=true) + DataLoader(data...; batchsize=1, shuffle=false, partial=true) An object that iterates over mini-batches of `data`, each mini-batch containing `batchsize` observations (except possibly the last one). diff --git a/src/data/iris.jl b/src/data/iris.jl index d78606d8..f74e0709 100644 --- a/src/data/iris.jl +++ b/src/data/iris.jl @@ -28,7 +28,6 @@ function load() end """ - labels() Get the labels of the iris dataset, a 150 element array of strings listing the @@ -53,7 +52,6 @@ function labels() end """ - features() Get the features of the iris dataset. This is a 4x150 matrix of Float64 diff --git a/src/optimise/optimisers.jl b/src/optimise/optimisers.jl index cf4496f4..75ba8618 100644 --- a/src/optimise/optimisers.jl +++ b/src/optimise/optimisers.jl @@ -6,7 +6,7 @@ const ϵ = 1e-8 # TODO: should use weak refs """ - Descent(η) + Descent(η) Classic gradient descent optimiser with learning rate `η`. For each parameter `p` and its gradient `δp`, this runs `p -= η*δp` @@ -441,7 +441,7 @@ function apply!(o::Optimiser, x, Δ) end """ - InvDecay(γ) + InvDecay(γ) Applies inverse time decay to an optimiser, i.e., the effective step size at iteration `n` is `eta / (1 + γ * n)` where `eta` is the initial step size. The wrapped optimiser's step size is not modified. ``` @@ -470,7 +470,7 @@ function apply!(o::InvDecay, x, Δ) end """ - ExpDecay(eta, decay, decay_step, clip) + ExpDecay(eta, decay, decay_step, clip) Discount the learning rate `eta` by a multiplicative factor `decay` every `decay_step` till a minimum of `clip`. @@ -509,7 +509,7 @@ function apply!(o::ExpDecay, x, Δ) end """ - WeightDecay(wd) + WeightDecay(wd) Decays the weight by `wd` diff --git a/src/optimise/train.jl b/src/optimise/train.jl index 79ebcc06..e12ab27b 100644 --- a/src/optimise/train.jl +++ b/src/optimise/train.jl @@ -3,8 +3,8 @@ import Zygote: Params, gradient """ - update!(opt, p, g) - update!(opt, ps::Params, gs) + update!(opt, p, g) + update!(opt, ps::Params, gs) Perform an update step of the parameters `ps` (or the single parameter `p`) according to optimizer `opt` and the gradients `gs` (the gradient `g`). diff --git a/src/utils.jl b/src/utils.jl index 2dba21c7..f483c5d9 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -60,7 +60,7 @@ head(x::Tuple) = reverse(Base.tail(reverse(x))) squeezebatch(x) = reshape(x, head(size(x))) """ - batch(xs) + batch(xs) Batch the arrays in `xs` into a single array. From f4365dab94e6cc2f46e7604f5ba1de311617db28 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Sun, 1 Mar 2020 15:19:22 +0100 Subject: [PATCH 2/3] fix docstring example indentation as well --- src/optimise/optimisers.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/optimise/optimisers.jl b/src/optimise/optimisers.jl index 75ba8618..c8e00126 100644 --- a/src/optimise/optimisers.jl +++ b/src/optimise/optimisers.jl @@ -451,7 +451,7 @@ Applies inverse time decay to an optimiser, i.e., the effective step size at ite ## Example ```julia - Optimiser(InvDecay(..), Opt(..)) +Optimiser(InvDecay(..), Opt(..)) ``` """ mutable struct InvDecay @@ -483,9 +483,8 @@ Discount the learning rate `eta` by a multiplicative factor `decay` every `decay ## Example To apply exponential decay to an optimiser: ```julia - Optimiser(ExpDecay(..), Opt(..)) - - opt = Optimiser(ExpDecay(), ADAM()) +Optimiser(ExpDecay(..), Opt(..)) +opt = Optimiser(ExpDecay(), ADAM()) ``` """ mutable struct ExpDecay From d67a2e40b3039830c68253e973d292257e00537a Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Sun, 1 Mar 2020 15:20:40 +0100 Subject: [PATCH 3/3] remove stray code block start from docstring --- src/optimise/optimisers.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/optimise/optimisers.jl b/src/optimise/optimisers.jl index c8e00126..f853ac23 100644 --- a/src/optimise/optimisers.jl +++ b/src/optimise/optimisers.jl @@ -444,7 +444,6 @@ end InvDecay(γ) Applies inverse time decay to an optimiser, i.e., the effective step size at iteration `n` is `eta / (1 + γ * n)` where `eta` is the initial step size. The wrapped optimiser's step size is not modified. -``` ## Parameters - gamma (γ): Defaults to `0.001`