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.
194
195
196
197
198
|
# File 'lib/dnn/core/layers.rb', line 194
def initialize(shape)
super()
@shape = shape
@x_shape = nil
end
|
Instance Attribute Details
#shape ⇒ Object
Returns the value of attribute shape.
192
193
194
|
# File 'lib/dnn/core/layers.rb', line 192
def shape
@shape
end
|
Class Method Details
.load_hash(hash) ⇒ Object
200
201
202
|
# File 'lib/dnn/core/layers.rb', line 200
def self.load_hash(hash)
self.new(hash[:shape])
end
|
Instance Method Details
#backward(dout) ⇒ Object
209
210
211
|
# File 'lib/dnn/core/layers.rb', line 209
def backward(dout)
dout.reshape(*@x_shape)
end
|
#forward(x) ⇒ Object
204
205
206
207
|
# File 'lib/dnn/core/layers.rb', line 204
def forward(x)
@x_shape = x.shape
x.reshape(x.shape[0], *@shape)
end
|
#to_hash ⇒ Object
213
214
215
|
# File 'lib/dnn/core/layers.rb', line 213
def to_hash
super({shape: @shape})
end
|