Class: Micrograd::MulOp
- Inherits:
-
Struct
- Object
- Struct
- Micrograd::MulOp
- Defined in:
- lib/micrograd/op.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
18 19 20 |
# File 'lib/micrograd/op.rb', line 18 def x @x end |
#y ⇒ Object
Returns the value of attribute y
18 19 20 |
# File 'lib/micrograd/op.rb', line 18 def y @y end |
Instance Method Details
#backward(value) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/micrograd/op.rb', line 19 def backward(value) x.grad += y.data * value.grad y.grad += x.data * value.grad x.backward y.backward end |