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

add Multiplication + finish Variable file

parent 42174698
Branches
No related tags found
No related merge requests found
...@@ -81,7 +81,7 @@ class Mul(_Function): ...@@ -81,7 +81,7 @@ class Mul(_Function):
# TODO: Implement the forward pass and put the result in self.result. # TODO: Implement the forward pass and put the result in self.result.
# The notbook provide you the formulas for this operation. # The notbook provide you the formulas for this operation.
####################################################################### #######################################################################
self.result = None self.result = x.data * y.data
####################################################################### #######################################################################
# --------------------------- END OF YOUR CODE ------------------------ # --------------------------- END OF YOUR CODE ------------------------
####################################################################### #######################################################################
...@@ -91,8 +91,8 @@ class Mul(_Function): ...@@ -91,8 +91,8 @@ class Mul(_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 = None self.dx = grad * y.data
self.dy = None self.dy = grad * x.data
####################################################################### #######################################################################
# --------------------------- END OF YOUR CODE ------------------------ # --------------------------- END OF YOUR CODE ------------------------
####################################################################### #######################################################################
......
...@@ -118,7 +118,7 @@ class Variable: ...@@ -118,7 +118,7 @@ class Variable:
# TODO: Update the current grad (self.grad), if the previous value # TODO: Update the current grad (self.grad), if the previous value
# is None. What should be the update ? # is None. What should be the update ?
####################################################################### #######################################################################
pass self.grad = grad
####################################################################### #######################################################################
# --------------------------- END OF YOUR CODE ------------------------ # --------------------------- END OF YOUR CODE ------------------------
####################################################################### #######################################################################
...@@ -127,7 +127,7 @@ class Variable: ...@@ -127,7 +127,7 @@ class Variable:
# TODO: Update the current grad(self.grad), if the previous value # TODO: 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 ?
####################################################################### #######################################################################
pass self.grad = self.grad + grad
####################################################################### #######################################################################
# --------------------------- END OF YOUR CODE ------------------------ # --------------------------- END OF YOUR CODE ------------------------
####################################################################### #######################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment