Class: DNN::Optimizers::SGD
- Defined in:
- lib/dnn/core/optimizers.rb
Instance Attribute Summary collapse
-
#momentum ⇒ Float
Return the momentum coefficient.
Attributes inherited from Optimizer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(learning_rate = 0.01, momentum: 0) ⇒ SGD
constructor
A new instance of SGD.
- #to_hash ⇒ Object
Methods inherited from Optimizer
Constructor Details
#initialize(learning_rate = 0.01, momentum: 0) ⇒ SGD
Returns a new instance of SGD.
48 49 50 51 52 |
# File 'lib/dnn/core/optimizers.rb', line 48 def initialize(learning_rate = 0.01, momentum: 0) super(learning_rate) @momentum = momentum @v = {} end |
Instance Attribute Details
#momentum ⇒ Float
Return the momentum coefficient.
40 41 42 |
# File 'lib/dnn/core/optimizers.rb', line 40 def momentum @momentum end |
Class Method Details
.from_hash(hash) ⇒ Object
42 43 44 |
# File 'lib/dnn/core/optimizers.rb', line 42 def self.from_hash(hash) self.new(hash[:learning_rate], momentum: hash[:momentum]) end |
Instance Method Details
#to_hash ⇒ Object
54 55 56 |
# File 'lib/dnn/core/optimizers.rb', line 54 def to_hash super(momentum: @momentum) end |