Class: DNN::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/dnn/core/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prev = nil, layer_node = nil) ⇒ Link



6
7
8
9
# File 'lib/dnn/core/link.rb', line 6

def initialize(prev = nil, layer_node = nil)
  @prev = prev
  @layer_node = layer_node
end

Instance Attribute Details

#layer_nodeObject

Returns the value of attribute layer_node.



4
5
6
# File 'lib/dnn/core/link.rb', line 4

def layer_node
  @layer_node
end

#prevObject

Returns the value of attribute prev.



3
4
5
# File 'lib/dnn/core/link.rb', line 3

def prev
  @prev
end

Instance Method Details

#backward(dy = Numo::SFloat[1]) ⇒ Object



11
12
13
14
# File 'lib/dnn/core/link.rb', line 11

def backward(dy = Numo::SFloat[1])
  dy = @layer_node.backward_node(dy)
  @prev&.backward(dy)
end