Class: DNN::Optimizers::Adam
- Defined in:
- lib/dnn/core/optimizers.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #alpha  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute alpha. 
- 
  
    
      #amsgrad  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute amsgrad. 
- 
  
    
      #beta1  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute beta1. 
- 
  
    
      #beta2  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute beta2. 
- 
  
    
      #eps  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute eps. 
Attributes inherited from Optimizer
Instance Method Summary collapse
- 
  
    
      #initialize(alpha: 0.001, beta1: 0.9, beta2: 0.999, eps: 1e-7, amsgrad: false, clip_norm: nil)  ⇒ Adam 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Adam. 
- #load_hash(hash) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Optimizer
from_hash, #update, #update_layers
Constructor Details
#initialize(alpha: 0.001, beta1: 0.9, beta2: 0.999, eps: 1e-7, amsgrad: false, clip_norm: nil) ⇒ Adam
Returns a new instance of Adam.
| 263 264 265 266 267 268 269 270 271 272 273 274 275 | # File 'lib/dnn/core/optimizers.rb', line 263 def initialize(alpha: 0.001, beta1: 0.9, beta2: 0.999, eps: 1e-7, amsgrad: false, clip_norm: nil) super(clip_norm: clip_norm) @alpha = alpha @beta1 = beta1 @beta2 = beta2 @eps = eps @amsgrad = amsgrad @t = 0 @m = {} @v = {} @s = amsgrad ? {} : nil @status = { m: @m, v: @v, s: @s } end | 
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
| 252 253 254 | # File 'lib/dnn/core/optimizers.rb', line 252 def alpha @alpha end | 
#amsgrad ⇒ Object (readonly)
Returns the value of attribute amsgrad.
| 256 257 258 | # File 'lib/dnn/core/optimizers.rb', line 256 def amsgrad @amsgrad end | 
#beta1 ⇒ Object
Returns the value of attribute beta1.
| 253 254 255 | # File 'lib/dnn/core/optimizers.rb', line 253 def beta1 @beta1 end | 
#beta2 ⇒ Object
Returns the value of attribute beta2.
| 254 255 256 | # File 'lib/dnn/core/optimizers.rb', line 254 def beta2 @beta2 end | 
#eps ⇒ Object
Returns the value of attribute eps.
| 255 256 257 | # File 'lib/dnn/core/optimizers.rb', line 255 def eps @eps end | 
Instance Method Details
#load_hash(hash) ⇒ Object
| 302 303 304 305 | # File 'lib/dnn/core/optimizers.rb', line 302 def load_hash(hash) initialize(alpha: hash[:alpha], beta1: hash[:beta1], beta2: hash[:beta2], eps: hash[:eps], amsgrad: hash[:amsgrad], clip_norm: hash[:clip_norm]) end | 
#to_hash ⇒ Object
| 277 278 279 280 281 282 | # File 'lib/dnn/core/optimizers.rb', line 277 def to_hash { class: self.class.name, alpha: @alpha, beta1: @beta1, beta2: @beta2, eps: @eps, amsgrad: @amsgrad, clip_norm: @clip_norm } end |