Class: DNN::Layers::Reshape
Instance Attribute Summary collapse
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
Instance Method Summary collapse
- #backward(dout) ⇒ Object
- #forward(x) ⇒ Object
-
#initialize(shape) ⇒ Reshape
constructor
A new instance of Reshape.
Methods inherited from Layer
Constructor Details
#initialize(shape) ⇒ Reshape
Returns a new instance of Reshape.
286 287 288 289 |
# File 'lib/dnn/core/layers.rb', line 286 def initialize(shape) @shape = shape @x_shape = nil end |
Instance Attribute Details
#shape ⇒ Object (readonly)
Returns the value of attribute shape.
284 285 286 |
# File 'lib/dnn/core/layers.rb', line 284 def shape @shape end |
Instance Method Details
#backward(dout) ⇒ Object
296 297 298 |
# File 'lib/dnn/core/layers.rb', line 296 def backward(dout) dout.reshape(@x_shape) end |
#forward(x) ⇒ Object
291 292 293 294 |
# File 'lib/dnn/core/layers.rb', line 291 def forward(x) @x_shape = x.shape x.reshape(*@shape) end |