Class: DNN::Layers::Add

Inherits:
MergeLayer show all
Includes:
LayerNode
Defined in:
lib/dnn/core/layers/math_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 MergeLayer

call, #call

Methods inherited from Layer

#<<, #build, #built?, #call, call, #clean, #compute_output_shape, #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



72
73
74
75
76
# File 'lib/dnn/core/layers/math_layers.rb', line 72

def backward_node(dy)
  dx1 = MathUtils.sum_to(dy, @x1_shape)
  dx2 = MathUtils.sum_to(dy, @x2_shape)
  [dx1, dx2]
end

#forward_node(x1, x2) ⇒ Object



66
67
68
69
70
# File 'lib/dnn/core/layers/math_layers.rb', line 66

def forward_node(x1, x2)
  @x1_shape = x1.shape
  @x2_shape = x2.shape
  x1 + x2
end