Class: DNN::Layers::Flatten

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

Instance Attribute Summary

Attributes inherited from Layer

#input_shape

Instance Method Summary collapse

Methods inherited from Layer

#build, #built?, call, #call, #clean, from_hash, #initialize, #load_hash, #to_hash

Constructor Details

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

Instance Method Details

#backward(dy) ⇒ Object



314
315
316
# File 'lib/dnn/core/layers/basic_layers.rb', line 314

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

#forward(x) ⇒ Object



310
311
312
# File 'lib/dnn/core/layers/basic_layers.rb', line 310

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

#output_shapeObject



318
319
320
# File 'lib/dnn/core/layers/basic_layers.rb', line 318

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