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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lr = 0.01, momentum: 0, clip_norm: nil) ⇒ SGD
constructor
A new instance of SGD.
- #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.
72 73 74 75 76 77 78 |
# File 'lib/dnn/core/optimizers.rb', line 72 def initialize(lr = 0.01, momentum: 0, clip_norm: nil) super(clip_norm: clip_norm) @lr = lr @momentum = momentum @v = {} @status = { v: @v } end |
Instance Attribute Details
#lr ⇒ Object
Returns the value of attribute lr.
63 64 65 |
# File 'lib/dnn/core/optimizers.rb', line 63 def lr @lr end |
#momentum ⇒ Object
Returns the value of attribute momentum.
64 65 66 |
# File 'lib/dnn/core/optimizers.rb', line 64 def momentum @momentum end |
Class Method Details
.from_hash(hash) ⇒ Object
66 67 68 |
# File 'lib/dnn/core/optimizers.rb', line 66 def self.from_hash(hash) self.new(hash[:lr], momentum: hash[:momentum], clip_norm: hash[:clip_norm]) end |
Instance Method Details
#to_hash ⇒ Object
80 81 82 |
# File 'lib/dnn/core/optimizers.rb', line 80 def to_hash super(lr: @lr, momentum: @momentum) end |