Class: DNN::Layers::Layer
- Inherits:
-
Object
- Object
- DNN::Layers::Layer
- Defined in:
- lib/dnn/core/layers.rb
Overview
Super class of all optimizer classes.
Direct Known Subclasses
Activations::ELU, Activations::LeakyReLU, Activations::ReLU, Activations::Sigmoid, Activations::Softplus, Activations::Softsign, Activations::Swish, Activations::Tanh, Dropout, Flatten, HasParamLayer, InputLayer, Pool2D, Reshape, UnPool2D
Instance Attribute Summary collapse
-
#input_shape ⇒ Array
readonly
Return the shape of the input data.
-
#learning_phase ⇒ Bool
Learning_phase Return the true if learning.
Instance Method Summary collapse
-
#backward(dy) ⇒ Object
Backward propagation.
-
#build(input_shape) ⇒ Object
Build the layer.
-
#built? ⇒ Bool
Does the layer have already been built?.
-
#forward(x) ⇒ Object
Forward propagation.
-
#initialize ⇒ Layer
constructor
A new instance of Layer.
-
#output_shape ⇒ Array
Please reimplement this method as needed.
-
#to_hash(merge_hash = nil) ⇒ Object
Layer to a hash.
Constructor Details
#initialize ⇒ Layer
Returns a new instance of Layer.
11 12 13 |
# File 'lib/dnn/core/layers.rb', line 11 def initialize @built = false end |
Instance Attribute Details
#input_shape ⇒ Array (readonly)
Return the shape of the input data.
9 10 11 |
# File 'lib/dnn/core/layers.rb', line 9 def input_shape @input_shape end |
#learning_phase ⇒ Bool
Returns learning_phase Return the true if learning.
7 8 9 |
# File 'lib/dnn/core/layers.rb', line 7 def learning_phase @learning_phase end |
Instance Method Details
#backward(dy) ⇒ Object
Backward propagation.
35 36 37 |
# File 'lib/dnn/core/layers.rb', line 35 def backward(dy) raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'backward'") end |
#build(input_shape) ⇒ Object
Build the layer.
17 18 19 20 21 |
# File 'lib/dnn/core/layers.rb', line 17 def build(input_shape) @input_shape = input_shape @learning_phase = true @built = true end |
#built? ⇒ Bool
Does the layer have already been built?
25 26 27 |
# File 'lib/dnn/core/layers.rb', line 25 def built? @built end |
#forward(x) ⇒ Object
Forward propagation.
30 31 32 |
# File 'lib/dnn/core/layers.rb', line 30 def forward(x) raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'forward'") end |
#output_shape ⇒ Array
Please reimplement this method as needed. The default implementation return input_shape.
42 43 44 |
# File 'lib/dnn/core/layers.rb', line 42 def output_shape @input_shape end |
#to_hash(merge_hash = nil) ⇒ Object
Layer to a hash.
47 48 49 50 51 |
# File 'lib/dnn/core/layers.rb', line 47 def to_hash(merge_hash = nil) hash = {class: self.class.name} hash.merge!(merge_hash) if merge_hash hash end |