Class: DNN::Layers::Flatten

Inherits:
Layer
  • Object
show all
Defined in:
lib/dnn/core/layers.rb

Instance Method Summary collapse

Methods inherited from Layer

#init, #prev_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

#shapeObject



277
278
279
# File 'lib/dnn/core/layers.rb', line 277

def shape
  [prev_layer.shape.reduce(:*)]
end