Class: DNN::Layers::Flatten

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

Instance Method Summary collapse

Methods inherited from Layer

#build, #built?, #initialize, #prev_layer, #to_hash

Constructor Details

This class inherits a constructor from DNN::Layers::Layer

Instance Method Details

#backward(dout) ⇒ Object



226
227
228
# File 'lib/dnn/core/layers.rb', line 226

def backward(dout)
  dout.reshape(*@shape)
end

#forward(x) ⇒ Object



221
222
223
224
# File 'lib/dnn/core/layers.rb', line 221

def forward(x)
  @shape = x.shape
  x.reshape(x.shape[0], x.shape[1..-1].reduce(:*))
end

#shape ⇒ Object



230
231
232
# File 'lib/dnn/core/layers.rb', line 230

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