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



239
240
241
# File 'lib/dnn/core/layers.rb', line 239

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

#forward(x) ⇒ Object



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

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

#output_shape ⇒ Object



243
244
245
# File 'lib/dnn/core/layers.rb', line 243

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