Class: Micrograd::AddOp

Inherits:
Struct
  • Object
show all
Defined in:
lib/micrograd/op.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



8
9
10
# File 'lib/micrograd/op.rb', line 8

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



8
9
10
# File 'lib/micrograd/op.rb', line 8

def y
  @y
end

Instance Method Details

#backward(value) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/micrograd/op.rb', line 9

def backward(value)
  x.grad += value.grad
  y.grad += value.grad

  x.backward
  y.backward
end