diff --git a/functions.py b/functions.py index cf808d0caaa533a754f35d3a3a023af342d86115..fc1b6f45ee1d304684e60f24154b6cf776ab3978 100644 --- a/functions.py +++ b/functions.py @@ -143,8 +143,8 @@ class MatMul(_Function): # TODO: Implement the derivative dx for this opetation and add the # result of the chain rule on self.dx. ####################################################################### - self.dx = grad * np.add(self.x.data, self.y.data.transpose()) - self.dy = grad * np.add(self.x.data.transpose(), self.y.data) + self.dx = grad.dot(self.y.data.transpose()) + self.dy = grad.dot(self.x.data.transpose()) ####################################################################### # --------------------------- END OF YOUR CODE ------------------------ ####################################################################### diff --git a/variable.py b/variable.py index 2690125c7f5b9e2172339f12676f9ab40ccf1dbf..a35ad1cc58d6c0ab2e9e60cf7d72d08f4728b35e 100644 --- a/variable.py +++ b/variable.py @@ -115,7 +115,7 @@ class Variable: "\n\tShape of data: {}".format(self.shape)) if self.grad is None: ####################################################################### - # TODO: Update the current grad (self.grad), if the previous value + # Update the current grad (self.grad), if the previous value # is None. What should be the update ? ####################################################################### self.grad = grad @@ -124,7 +124,7 @@ class Variable: ####################################################################### else: ####################################################################### - # TODO: Update the current grad(self.grad), if the previous value + # Update the current grad(self.grad), if the previous value # is not None. What should be the update ? ####################################################################### self.grad = self.grad + grad