Class: DNN::Layers::Flatten
Instance Method Summary collapse
Methods inherited from Layer
Instance Method Details
#backward(dout) ⇒ Object
273 274 275 |
# File 'lib/dnn/core/layers.rb', line 273 def backward(dout) dout.reshape(*@shape) end |
#forward(x) ⇒ Object
268 269 270 271 |
# File 'lib/dnn/core/layers.rb', line 268 def forward(x) @shape = x.shape x.reshape(x.shape[0], x.shape[1..-1].reduce(:*)) end |
#shape ⇒ Object
277 278 279 |
# File 'lib/dnn/core/layers.rb', line 277 def shape [prev_layer.shape.reduce(:*)] end |