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 ⇒ Object
readonly
Returns the value of attribute input_shape.
Instance Method Summary collapse
-
#backward(dout) ⇒ Object
Backward propagation.
-
#build(input_shape) ⇒ Object
Build the layer.
-
#built? ⇒ Boolean
Does the layer have already been built?.
-
#forward(x) ⇒ Object
Forward propagation.
-
#initialize ⇒ Layer
constructor
A new instance of Layer.
- #output_shape ⇒ Object
-
#to_hash(merge_hash = nil) ⇒ Object
Layer to a hash.
Constructor Details
#initialize ⇒ Layer
Returns a new instance of Layer.
8 9 10 |
# File 'lib/dnn/core/layers.rb', line 8 def initialize @built = false end |
Instance Attribute Details
#input_shape ⇒ Object (readonly)
Returns the value of attribute input_shape.
6 7 8 |
# File 'lib/dnn/core/layers.rb', line 6 def input_shape @input_shape end |
Instance Method Details
#backward(dout) ⇒ Object
Backward propagation.
29 30 31 |
# File 'lib/dnn/core/layers.rb', line 29 def backward(dout) raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'update'") end |
#build(input_shape) ⇒ Object
Build the layer.
13 14 15 16 |
# File 'lib/dnn/core/layers.rb', line 13 def build(input_shape) @input_shape = input_shape @built = true end |
#built? ⇒ Boolean
Does the layer have already been built?
19 20 21 |
# File 'lib/dnn/core/layers.rb', line 19 def built? @built end |
#forward(x) ⇒ Object
Forward propagation.
24 25 26 |
# File 'lib/dnn/core/layers.rb', line 24 def forward(x) raise NotImplementedError.new("Class '#{self.class.name}' has implement method 'forward'") end |
#output_shape ⇒ Object
33 34 35 |
# File 'lib/dnn/core/layers.rb', line 33 def output_shape @input_shape end |
#to_hash(merge_hash = nil) ⇒ Object
Layer to a hash.
38 39 40 41 42 |
# File 'lib/dnn/core/layers.rb', line 38 def to_hash(merge_hash = nil) hash = {class: self.class.name} hash.merge!(merge_hash) if merge_hash hash end |