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

Instance Method Summary collapse

Methods included from LayerNode

#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



301
302
303
# File 'lib/dnn/core/layers/basic_layers.rb', line 301

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

#compute_output_shapeObject



305
306
307
# File 'lib/dnn/core/layers/basic_layers.rb', line 305

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

#forward_node(x) ⇒ Object



297
298
299
# File 'lib/dnn/core/layers/basic_layers.rb', line 297

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