Class: DNN::Layers::Reshape
Instance Attribute Summary
Attributes inherited from Layer
#input_shape, #output_shape
Instance Method Summary
collapse
Methods included from LayerNode
#forward
Methods inherited from Layer
#<<, #build, #built?, #call, call, #clean, #forward, from_hash
Constructor Details
#initialize(shape) ⇒ Reshape
Returns a new instance of Reshape.
313
314
315
316
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 313
def initialize(shape)
super()
@shape = shape
end
|
Instance Method Details
#backward_node(dy) ⇒ Object
326
327
328
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 326
def backward_node(dy)
dy.reshape(dy.shape[0], *@input_shape)
end
|
#compute_output_shape ⇒ Object
318
319
320
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 318
def compute_output_shape
@shape
end
|
#forward_node(x) ⇒ Object
322
323
324
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 322
def forward_node(x)
x.reshape(x.shape[0], *@output_shape)
end
|
#load_hash(hash) ⇒ Object
334
335
336
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 334
def load_hash(hash)
initialize(hash[:shape])
end
|
#to_hash ⇒ Object
330
331
332
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 330
def to_hash
super(shape: @shape)
end
|