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 = nil) ⇒ Link

Returns a new instance of Link.



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

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

Instance Attribute Details

#layerObject

Returns the value of attribute layer.



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

def layer
  @layer
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) ⇒ Object



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

def backward(dy)
  dy = @layer.backward(dy)
  @prev&.backward(dy)
end