Class: Chainer::Optimizers::MomentumSGD
- Inherits:
-
GradientMethod
- Object
- Chainer::Optimizer
- GradientMethod
- Chainer::Optimizers::MomentumSGD
- Defined in:
- lib/chainer/optimizers/momentum_sgd.rb
Overview
Momentum SGD optimizer
Instance Attribute Summary collapse
-
#lr ⇒ Object
Returns the value of attribute lr.
-
#momentum ⇒ Object
Returns the value of attribute momentum.
Attributes inherited from Chainer::Optimizer
Instance Method Summary collapse
- #create_update_rule ⇒ Object
-
#initialize(lr: nil, momentum: nil) ⇒ MomentumSGD
constructor
A new instance of MomentumSGD.
Methods inherited from GradientMethod
#call_hooks, #reallocate_cleared_grads, #setup, #update
Methods inherited from Chainer::Optimizer
#_call_hook, #add_hook, #call_hooks, #serialize, #setup
Constructor Details
#initialize(lr: nil, momentum: nil) ⇒ MomentumSGD
Returns a new instance of MomentumSGD.
36 37 38 39 40 41 42 |
# File 'lib/chainer/optimizers/momentum_sgd.rb', line 36 def initialize(lr: nil, momentum: nil) super() @hyperparam.instance_variable_set('@lr', lr || 0.01) @hyperparam.instance_variable_set('@momentum', momentum || 0.9) Chainer::HyperparameterProxy.new(self, "lr") Chainer::HyperparameterProxy.new(self, "momentum") end |
Instance Attribute Details
#lr ⇒ Object
Returns the value of attribute lr.
33 34 35 |
# File 'lib/chainer/optimizers/momentum_sgd.rb', line 33 def lr @lr end |
#momentum ⇒ Object
Returns the value of attribute momentum.
33 34 35 |
# File 'lib/chainer/optimizers/momentum_sgd.rb', line 33 def momentum @momentum end |
Instance Method Details
#create_update_rule ⇒ Object
44 45 46 |
# File 'lib/chainer/optimizers/momentum_sgd.rb', line 44 def create_update_rule MomentumSGDRule.new(parent_hyperparam: @hyperparam) end |