Class: DNN::Layers::HasParamLayer
Overview
This class is a superclass of all classes with learning parameters.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
The parameters of the layer.
-
#trainable ⇒ Object
Setting false prevents learning of parameters.
Attributes inherited from Layer
Instance Method Summary collapse
- #build(input_shape) ⇒ Object
-
#initialize ⇒ HasParamLayer
constructor
A new instance of HasParamLayer.
-
#update(optimizer) ⇒ Object
Update the parameters.
Methods inherited from Layer
#backward, #built?, #forward, #output_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 = {} @trainable = true end |
Instance Attribute Details
#params ⇒ Object (readonly)
The parameters of the layer.
49 50 51 |
# File 'lib/dnn/core/layers.rb', line 49 def params @params end |
#trainable ⇒ Object
Setting false prevents learning of parameters.
48 49 50 |
# File 'lib/dnn/core/layers.rb', line 48 def trainable @trainable end |
Instance Method Details
#build(input_shape) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/dnn/core/layers.rb', line 57 def build(input_shape) @input_shape = input_shape unless @built @built = true init_params end end |
#update(optimizer) ⇒ Object
Update the parameters.
66 67 68 |
# File 'lib/dnn/core/layers.rb', line 66 def update(optimizer) optimizer.update(@params) if @trainable end |