Class: DNN::Layers::Reshape
- Inherits:
-
Layer
- Object
- Layer
- DNN::Layers::Reshape
show all
- Defined in:
- lib/dnn/core/layers/basic_layers.rb
Instance Attribute Summary collapse
Attributes inherited from Layer
#input_shape
Instance Method Summary
collapse
Methods inherited from Layer
#build, #built?, #call, call, #clean, from_hash
Constructor Details
#initialize(output_shape) ⇒ Reshape
Returns a new instance of Reshape.
326
327
328
329
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 326
def initialize(output_shape)
super()
@output_shape = output_shape
end
|
Instance Attribute Details
#output_shape ⇒ Object
Returns the value of attribute output_shape.
324
325
326
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 324
def output_shape
@output_shape
end
|
Instance Method Details
#backward(dy) ⇒ Object
335
336
337
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 335
def backward(dy)
dy.reshape(dy.shape[0], *@input_shape)
end
|
#forward(x) ⇒ Object
331
332
333
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 331
def forward(x)
x.reshape(x.shape[0], *@output_shape)
end
|
#load_hash(hash) ⇒ Object
343
344
345
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 343
def load_hash(hash)
initialize(hash[:output_shape])
end
|
#to_hash ⇒ Object
339
340
341
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 339
def to_hash
super(output_shape: @output_shape)
end
|