Class: DNN::Link
- Inherits:
-
Object
- Object
- DNN::Link
- Defined in:
- lib/dnn/core/link.rb
Instance Attribute Summary collapse
-
#layer_node ⇒ Object
Returns the value of attribute layer_node.
-
#next ⇒ Object
Returns the value of attribute next.
-
#prev ⇒ Object
Returns the value of attribute prev.
Instance Method Summary collapse
- #backward(dy = Xumo::SFloat[1]) ⇒ Object
- #forward(x) ⇒ Object
-
#initialize(prev = nil, layer_node = nil) ⇒ Link
constructor
A new instance of Link.
Constructor Details
#initialize(prev = nil, layer_node = nil) ⇒ Link
Returns a new instance of Link.
7 8 9 10 11 |
# File 'lib/dnn/core/link.rb', line 7 def initialize(prev = nil, layer_node = nil) @prev = prev @layer_node = layer_node @next = nil end |
Instance Attribute Details
#layer_node ⇒ Object
Returns the value of attribute layer_node.
5 6 7 |
# File 'lib/dnn/core/link.rb', line 5 def layer_node @layer_node end |
#next ⇒ Object
Returns the value of attribute next.
4 5 6 |
# File 'lib/dnn/core/link.rb', line 4 def next @next end |
#prev ⇒ Object
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 = Xumo::SFloat[1]) ⇒ Object
18 19 20 21 |
# File 'lib/dnn/core/link.rb', line 18 def backward(dy = Xumo::SFloat[1]) dy = @layer_node.backward_node(dy) @prev&.backward(dy) end |
#forward(x) ⇒ Object
13 14 15 16 |
# File 'lib/dnn/core/link.rb', line 13 def forward(x) x = @layer_node.(x) @next ? @next.forward(x) : x end |