Skip to content

Commit c1c8beb

Browse files
authored
add comments from PR46 (#60)
1 parent 3858611 commit c1c8beb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Optimisers"
22
uuid = "3bd65402-5787-11e9-1adc-39752487f4e2"
33
authors = ["Mike J Innes <[email protected]>"]
4-
version = "0.2.2"
4+
version = "0.2.1"
55

66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/rules.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,24 @@ end
442442
"""
443443
WeightDecay(γ = 5f-4)
444444
445-
Decay weights by `γ`.
445+
Decay weights by ``γ``, that is, add `γ .* x` to the gradient `x̄` which will be
446+
subtracted from `x`.
447+
448+
Typically composed with other optimisers as the first transformation in an [`OptimiserChain`](@ref).
449+
This is equivalent to adding ``L_2`` regularization with coefficient ``γ`` to the loss.
446450
447451
# Parameters
448452
- Weight decay (`γ`): Decay applied to weights during optimisation.
449453
"""
450454
struct WeightDecay{T}
451-
wd::T
455+
gamma::T
452456
end
453457
WeightDecay() = WeightDecay(5f-4)
454458

455459
init(o::WeightDecay, x::AbstractArray) = nothing
456460

457461
function apply!(o::WeightDecay, state, x, dx)
458-
dx′ = @lazy dx + o.wd * x
462+
dx′ = @lazy dx + o.gamma * x
459463

460464
return state, dx′
461465
end

0 commit comments

Comments
 (0)