From c941cfede70469fab529e37ca458b4fdf15ad253 Mon Sep 17 00:00:00 2001
From: Maxxhim <maxc2507@gmail.com>
Date: Fri, 3 Apr 2020 00:28:54 +0200
Subject: [PATCH] add Multiplication + finish Variable file

---
 functions.py | 6 +++---
 variable.py  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/functions.py b/functions.py
index e50c421..f93daed 100644
--- a/functions.py
+++ b/functions.py
@@ -81,7 +81,7 @@ class Mul(_Function):
         # TODO: Implement the forward pass and put the result in self.result.
         # The notbook provide you the formulas for this operation.
         #######################################################################
-        self.result = None
+        self.result = x.data * y.data
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -91,8 +91,8 @@ class Mul(_Function):
         # TODO: Implement the derivative dx for this opetation and add the
         # result of the chain rule on self.dx.
         #######################################################################
-        self.dx = None
-        self.dy = None
+        self.dx = grad * y.data
+        self.dy = grad * x.data
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
diff --git a/variable.py b/variable.py
index e7426a4..2690125 100644
--- a/variable.py
+++ b/variable.py
@@ -118,7 +118,7 @@ class Variable:
             # TODO: Update the current grad (self.grad), if the previous value
             # is None. What should be the update ?
             #######################################################################
-            pass
+            self.grad = grad
             #######################################################################
             # --------------------------- END OF YOUR CODE ------------------------
             #######################################################################
@@ -127,7 +127,7 @@ class Variable:
             # TODO: Update the current grad(self.grad), if the previous value
             # is not None. What should be the update ?
             #######################################################################
-            pass
+            self.grad = self.grad + grad
             #######################################################################
             # --------------------------- END OF YOUR CODE ------------------------
             #######################################################################
-- 
GitLab