Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bitgrad/grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def _backward():

return out

def __truediv__(self,other):
def __truediv__(self, other):
other = other if isinstance(other, Value) else Value(other)
out = Value(self.data * other.data**(-1.0), (self, other), 'truediv')
out = Value(self.data / other.data, (self, other), 'truediv')

def _backward():
self.grad += other.data**(-1.0) * out.grad
other.grad += self.data * out.grad
self.grad += (1.0 / other.data) * out.grad
other.grad += (-self.data / (other.data ** 2)) * out.grad
out._backward = _backward

return out
Expand Down