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



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

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

#compute_output_shapeObject



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

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

#forward_node(x) ⇒ Object



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

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