Class: DNN::Layers::HasParamLayer
Overview
This class is a superclass of all classes with learning parameters.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#grads ⇒ Object
readonly
Differential value of parameter of layer.
-
#params ⇒ Object
readonly
The parameters of the layer.
Instance Method Summary collapse
- #build(model) ⇒ Object
-
#initialize ⇒ HasParamLayer
constructor
A new instance of HasParamLayer.
-
#update ⇒ Object
Update the parameters.
Methods inherited from Layer
#backward, #built?, #forward, #prev_layer, #shape, #to_hash
Constructor Details
#initialize ⇒ HasParamLayer
Returns a new instance of HasParamLayer.
51 52 53 54 55 |
# File 'lib/dnn/core/layers.rb', line 51 def initialize super @params = {} @grads = {} end |
Instance Attribute Details
#grads ⇒ Object (readonly)
Differential value of parameter of layer.
49 50 51 |
# File 'lib/dnn/core/layers.rb', line 49 def grads @grads end |
#params ⇒ Object (readonly)
The parameters of the layer.
48 49 50 |
# File 'lib/dnn/core/layers.rb', line 48 def params @params end |
Instance Method Details
#build(model) ⇒ Object
57 58 59 60 |
# File 'lib/dnn/core/layers.rb', line 57 def build(model) super init_params end |
#update ⇒ Object
Update the parameters.
63 64 65 |
# File 'lib/dnn/core/layers.rb', line 63 def update @model.optimizer.update(self) end |