Class: DNN::Layers::Flatten

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

Instance Attribute Summary

Attributes inherited from Layer

#input_shape

Instance Method Summary collapse

Methods inherited from Layer

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

Constructor Details

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

Instance Method Details

#backward(dout) ⇒ Object



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

def backward(dout)
  dout.reshape(dout.shape[0], *@input_shape)
end

#forward(x) ⇒ Object



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

def forward(x)
  x.reshape(x.shape[0], *output_shape)
end

#output_shapeObject



234
235
236
# File 'lib/dnn/core/layers.rb', line 234

def output_shape
  [@input_shape.reduce(:*)]
end