Class: DNN::Layers::Flatten

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

Instance Attribute Summary

Attributes inherited from Layer

#input_shape

Instance Method Summary collapse

Methods included from LayerNode

#backward, #forward

Methods inherited from Layer

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

Constructor Details

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

Instance Method Details

#backward_node(dy) ⇒ Object



335
336
337
# File 'lib/dnn/core/layers/basic_layers.rb', line 335

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

#forward_node(x) ⇒ Object



331
332
333
# File 'lib/dnn/core/layers/basic_layers.rb', line 331

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

#output_shapeObject



339
340
341
# File 'lib/dnn/core/layers/basic_layers.rb', line 339

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