Class: DNN::Optimizers::RMSProp
- Defined in:
- lib/dnn/core/optimizers.rb
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
Attributes inherited from Optimizer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(learning_rate = 0.001, alpha: 0.9) ⇒ RMSProp
constructor
A new instance of RMSProp.
- #to_hash ⇒ Object
- #update(params) ⇒ Object
Constructor Details
#initialize(learning_rate = 0.001, alpha: 0.9) ⇒ RMSProp
Returns a new instance of RMSProp.
104 105 106 107 108 |
# File 'lib/dnn/core/optimizers.rb', line 104 def initialize(learning_rate = 0.001, alpha: 0.9) super(learning_rate) @alpha = alpha @g = {} end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
98 99 100 |
# File 'lib/dnn/core/optimizers.rb', line 98 def alpha @alpha end |
Class Method Details
.load_hash(hash) ⇒ Object
100 101 102 |
# File 'lib/dnn/core/optimizers.rb', line 100 def self.load_hash(hash) self.new(hash[:learning_rate], alpha: hash[:alpha]) end |
Instance Method Details
#to_hash ⇒ Object
118 119 120 |
# File 'lib/dnn/core/optimizers.rb', line 118 def to_hash super({alpha: @alpha}) end |
#update(params) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/dnn/core/optimizers.rb', line 110 def update(params) params.select { |key, param| param.grad }.each_value do |param| @g[param] ||= 0 @g[param] = @alpha * @g[param] + (1 - @alpha) * param.grad**2 param.data -= (@learning_rate / NMath.sqrt(@g[param] + 1e-7)) * param.grad end end |