Class: DNN::Layers::HasParamLayer

Inherits:
Layer
  • Object
show all
Defined in:
lib/dnn/core/layers.rb

Overview

This class is a superclass of all classes with learning parameters.

Direct Known Subclasses

BatchNormalization, Conv2D, Dense

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Layer

#backward, #built?, #forward, #prev_layer, #shape, #to_hash

Constructor Details

#initialize ⇒ HasParamLayer

Returns a new instance of HasParamLayer.



53
54
55
56
57
# File 'lib/dnn/core/layers.rb', line 53

def initialize
  super
  @params = {}
  @grads = {}
end

Instance Attribute Details

#grads ⇒ Object (readonly)

Differential value of parameter of layer.



51
52
53
# File 'lib/dnn/core/layers.rb', line 51

def grads
  @grads
end

#params ⇒ Object (readonly)

The parameters of the layer.



50
51
52
# File 'lib/dnn/core/layers.rb', line 50

def params
  @params
end

Instance Method Details

#build(model) ⇒ Object



59
60
61
62
# File 'lib/dnn/core/layers.rb', line 59

def build(model)
  super
  init_params
end

#update ⇒ Object

Update the parameters.



65
66
67
# File 'lib/dnn/core/layers.rb', line 65

def update
  @model.optimizer.update(self)
end