Class: Chainer::WeightDecay
- Inherits:
-
Object
- Object
- Chainer::WeightDecay
- Defined in:
- lib/chainer/optimizer.rb
Overview
Optimizer/UpdateRule hook function for weight decay regularization
This hook function adds a scaled parameter to the correspondeing gradient It can be used as a regularization
Instance Method Summary collapse
- #call(rule, param) ⇒ Object
- #call_for_each_param ⇒ Object
-
#initialize(rate) ⇒ WeightDecay
constructor
A new instance of WeightDecay.
- #name ⇒ Object
Constructor Details
#initialize(rate) ⇒ WeightDecay
Returns a new instance of WeightDecay.
168 169 170 |
# File 'lib/chainer/optimizer.rb', line 168 def initialize(rate) @rate = rate end |
Instance Method Details
#call(rule, param) ⇒ Object
172 173 174 175 |
# File 'lib/chainer/optimizer.rb', line 172 def call(rule, param) return if param.data.nil? || param.grad.nil? param.grad += (@rate * param.data) end |
#call_for_each_param ⇒ Object
164 165 166 |
# File 'lib/chainer/optimizer.rb', line 164 def call_for_each_param true end |
#name ⇒ Object
160 161 162 |
# File 'lib/chainer/optimizer.rb', line 160 def name "WeightDecay" end |