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.
249
250
251
252
253
|
# File 'lib/dnn/core/layers.rb', line 249
def initialize(shape)
super()
@shape = shape
@x_shape = nil
end
|
Instance Attribute Details
#shape ⇒ Object
Returns the value of attribute shape.
247
248
249
|
# File 'lib/dnn/core/layers.rb', line 247
def shape
@shape
end
|
Class Method Details
.load_hash(hash) ⇒ Object
255
256
257
|
# File 'lib/dnn/core/layers.rb', line 255
def self.load_hash(hash)
self.new(hash[:shape])
end
|
Instance Method Details
#backward(dout) ⇒ Object
264
265
266
|
# File 'lib/dnn/core/layers.rb', line 264
def backward(dout)
dout.reshape(*@x_shape)
end
|
#forward(x) ⇒ Object
259
260
261
262
|
# File 'lib/dnn/core/layers.rb', line 259
def forward(x)
@x_shape = x.shape
x.reshape(x.shape[0], *@shape)
end
|
#to_hash ⇒ Object
268
269
270
|
# File 'lib/dnn/core/layers.rb', line 268
def to_hash
super({shape: @shape})
end
|