Class: DNN::Optimizers::SGD
- Defined in:
- lib/dnn/core/optimizers.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#lr ⇒ Object
Returns the value of attribute lr.
-
#momentum ⇒ Object
Returns the value of attribute momentum.
Attributes inherited from Optimizer
Instance Method Summary collapse
-
#initialize(lr: 0.01, momentum: 0, clip_norm: nil) ⇒ SGD
constructor
A new instance of SGD.
- #load_hash(hash) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Optimizer
Constructor Details
#initialize(lr: 0.01, momentum: 0, clip_norm: nil) ⇒ SGD
Returns a new instance of SGD.
66 67 68 69 70 71 |
# File 'lib/dnn/core/optimizers.rb', line 66 def initialize(lr: 0.01, momentum: 0, clip_norm: nil) super(clip_norm: clip_norm) @lr = lr @momentum = momentum @v = {} end |
Instance Attribute Details
#lr ⇒ Object
Returns the value of attribute lr.
61 62 63 |
# File 'lib/dnn/core/optimizers.rb', line 61 def lr @lr end |
#momentum ⇒ Object
Returns the value of attribute momentum.
62 63 64 |
# File 'lib/dnn/core/optimizers.rb', line 62 def momentum @momentum end |
Instance Method Details
#load_hash(hash) ⇒ Object
89 90 91 |
# File 'lib/dnn/core/optimizers.rb', line 89 def load_hash(hash) initialize(lr: hash[:lr], momentum: hash[:momentum], clip_norm: hash[:clip_norm]) end |
#to_hash ⇒ Object
73 74 75 |
# File 'lib/dnn/core/optimizers.rb', line 73 def to_hash super(lr: @lr, momentum: @momentum) end |