Class: Micrograd::TanhOp
- Inherits:
-
Struct
- Object
- Struct
- Micrograd::TanhOp
- Defined in:
- lib/micrograd/op.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
Instance Method Summary collapse
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
28 29 30 |
# File 'lib/micrograd/op.rb', line 28 def x @x end |
Instance Method Details
#backward(value) ⇒ Object
29 30 31 32 33 |
# File 'lib/micrograd/op.rb', line 29 def backward(value) x.grad += (1 - value.data**2) * value.grad x.backward rescue end |