Skip to content
Snippets Groups Projects
Commit 87d38cbc authored by Maxxhim's avatar Maxxhim
Browse files

patch v3 matrix mult

parent c7232b3e
No related branches found
No related tags found
No related merge requests found
...@@ -143,8 +143,8 @@ class MatMul(_Function): ...@@ -143,8 +143,8 @@ class MatMul(_Function):
# TODO: Implement the derivative dx for this opetation and add the # TODO: Implement the derivative dx for this opetation and add the
# result of the chain rule on self.dx. # result of the chain rule on self.dx.
####################################################################### #######################################################################
self.dx = grad * np.add(self.x.data, self.y.data.transpose()) self.dx = grad.dot(self.y.data.transpose())
self.dy = grad * np.add(self.x.data.transpose(), self.y.data) self.dy = grad.dot(self.x.data.transpose())
####################################################################### #######################################################################
# --------------------------- END OF YOUR CODE ------------------------ # --------------------------- END OF YOUR CODE ------------------------
####################################################################### #######################################################################
......
...@@ -115,7 +115,7 @@ class Variable: ...@@ -115,7 +115,7 @@ class Variable:
"\n\tShape of data: {}".format(self.shape)) "\n\tShape of data: {}".format(self.shape))
if self.grad is None: 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 ? # is None. What should be the update ?
####################################################################### #######################################################################
self.grad = grad self.grad = grad
...@@ -124,7 +124,7 @@ class Variable: ...@@ -124,7 +124,7 @@ class Variable:
####################################################################### #######################################################################
else: 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 ? # is not None. What should be the update ?
####################################################################### #######################################################################
self.grad = self.grad + grad self.grad = self.grad + grad
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment