diff --git a/bitgrad/grad.py b/bitgrad/grad.py index 8f2b258..d566dd0 100644 --- a/bitgrad/grad.py +++ b/bitgrad/grad.py @@ -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