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, #learning_phase

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(dy) ⇒ Object



228
229
230
# File 'lib/dnn/core/layers.rb', line 228

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

#forward(x) ⇒ Object



224
225
226
# File 'lib/dnn/core/layers.rb', line 224

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

#output_shape ⇒ Object



232
233
234
# File 'lib/dnn/core/layers.rb', line 232

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