Class: DNN::Layers::Reshape
- Inherits:
-
Layer
- Object
- Layer
- DNN::Layers::Reshape
show all
- Defined in:
- lib/dnn/core/layers.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Layer
#build, #built?, #prev_layer
Constructor Details
#initialize(shape) ⇒ Reshape
Returns a new instance of Reshape.
455
456
457
458
459
|
# File 'lib/dnn/core/layers.rb', line 455
def initialize(shape)
super()
@shape = shape
@x_shape = nil
end
|
Instance Attribute Details
#shape ⇒ Object
Returns the value of attribute shape.
453
454
455
|
# File 'lib/dnn/core/layers.rb', line 453
def shape
@shape
end
|
Class Method Details
.load_hash(hash) ⇒ Object
461
462
463
|
# File 'lib/dnn/core/layers.rb', line 461
def self.load_hash(hash)
self.new(hash[:shape])
end
|
Instance Method Details
#backward(dout) ⇒ Object
470
471
472
|
# File 'lib/dnn/core/layers.rb', line 470
def backward(dout)
dout.reshape(@x_shape)
end
|
#forward(x) ⇒ Object
465
466
467
468
|
# File 'lib/dnn/core/layers.rb', line 465
def forward(x)
@x_shape = x.shape
x.reshape(*@shape)
end
|
#to_hash ⇒ Object
474
475
476
|
# File 'lib/dnn/core/layers.rb', line 474
def to_hash
{name: self.class.name, shape: @shape}
end
|