Class: DNN::Optimizers::RMSProp

Inherits:
Optimizer show all
Defined in:
lib/dnn/core/optimizers.rb

Instance Attribute Summary collapse

Attributes inherited from Optimizer

#clip_norm, #status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Optimizer

#dump, load, #update

Constructor Details

#initialize(lr = 0.001, alpha: 0.9, eps: 1e-7, clip_norm: nil) ⇒ RMSProp

Returns a new instance of RMSProp.

Parameters:

  • lr (Float) (defaults to: 0.001) —

    Learning rate.

  • alpha (Float) (defaults to: 0.9) —

    Moving average index of past slopes.

  • eps (Float) (defaults to: 1e-7) —

    Value to avoid division by zero.



158
159
160
161
162
163
164
165
# File 'lib/dnn/core/optimizers.rb', line 158

def initialize(lr = 0.001, alpha: 0.9, eps: 1e-7, clip_norm: nil)
  super(clip_norm: clip_norm)
  @lr = lr
  @alpha = alpha
  @eps = eps
  @g = {}
  @status = { g: @g }
end

Instance Attribute Details

#alpha ⇒ Object

Returns the value of attribute alpha.



148
149
150
# File 'lib/dnn/core/optimizers.rb', line 148

def alpha
  @alpha
end

#eps ⇒ Object

Returns the value of attribute eps.



149
150
151
# File 'lib/dnn/core/optimizers.rb', line 149

def eps
  @eps
end

#lr ⇒ Object

Returns the value of attribute lr.



147
148
149
# File 'lib/dnn/core/optimizers.rb', line 147

def lr
  @lr
end

Class Method Details

.from_hash(hash) ⇒ Object



151
152
153
# File 'lib/dnn/core/optimizers.rb', line 151

def self.from_hash(hash)
  self.new(hash[:lr], alpha: hash[:alpha], eps: hash[:eps], clip_norm: hash[:clip_norm])
end

Instance Method Details

#to_hash ⇒ Object



167
168
169
# File 'lib/dnn/core/optimizers.rb', line 167

def to_hash
  super(lr: @lr, alpha: @alpha, eps: @eps)
end