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

Instance Method Summary collapse

Methods inherited from Layer

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

Constructor Details

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

Instance Method Details

#backward(dy) ⇒ Object



261
262
263
# File 'lib/dnn/core/layers.rb', line 261

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

#forward(x) ⇒ Object



257
258
259
# File 'lib/dnn/core/layers.rb', line 257

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

#output_shape ⇒ Object



265
266
267
# File 'lib/dnn/core/layers.rb', line 265

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