From 69b46d09178f69035b2d7d176da91f7ca99edd28 Mon Sep 17 00:00:00 2001
From: Maxxhim <maxc2507@gmail.com>
Date: Fri, 3 Apr 2020 14:07:55 +0200
Subject: [PATCH] patch v1.1 Exp, Log, Sin, Cos, Tan

---
 functions.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/functions.py b/functions.py
index 5160daf..ec4d573 100644
--- a/functions.py
+++ b/functions.py
@@ -169,7 +169,7 @@ class Exp(_Function):
         # TODO: Implement the derivative dx for this opetation and add the
         # result of the chain rule on self.dx.
         #######################################################################
-        self.dx = np.exp(self.x.data)
+        self.dx = grad * np.exp(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -184,7 +184,7 @@ class Log(_Function):
         # TODO: Implement the forward pass and put the result in self.result.
         # The notbook provide you the formulas for this operation.
         #######################################################################
-        self.result = 1/(self.x.data)
+        self.result = np.log(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -194,7 +194,7 @@ class Log(_Function):
         # TODO: Implement the derivative dx for this opetation and add the
         # result of the chain rule on self.dx.
         #######################################################################
-        self.dx = 1/(self.x.data)
+        self.dx = grad * 1/(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -209,7 +209,7 @@ class Sin(_Function):
         # TODO: Implement the forward pass and put the result in self.result.
         # The notbook provide you the formulas for this operation.
         #######################################################################
-        self.result = np.cos(self.x.data)
+        self.result = np.sin(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -219,7 +219,7 @@ class Sin(_Function):
         # TODO: Implement the derivative dx for this opetation and add the
         # result of the chain rule on self.dx.
         #######################################################################
-        self.dx = np.cos(self.x.data)
+        self.dx = grad * np.cos(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -234,7 +234,7 @@ class Cos(_Function):
         # TODO: Implement the forward pass and put the result in self.result.
         # The notbook provide you the formulas for this operation.
         #######################################################################
-        self.result = -np.sin(self.x.data)
+        self.result = np.cos(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -244,7 +244,7 @@ class Cos(_Function):
         # TODO: Implement the derivative dx for this opetation and add the
         # result of the chain rule on self.dx.
         #######################################################################
-        self.dx = -np.sin(self.x.data)
+        self.dx = grad * (-np.sin(self.x.data))
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -259,7 +259,7 @@ class Tan(_Function):
         # TODO: Implement the forward pass and put the result in self.result.
         # The notbook provide you the formulas for this operation.
         #######################################################################
-        self.result = 1/np.square(np.cos(self.x.data))
+        self.result = np.tan(self.x.data)
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
@@ -269,7 +269,7 @@ class Tan(_Function):
         # TODO: Implement the derivative dx for this opetation and add the
         # result of the chain rule on self.dx.
         #######################################################################
-        self.dx = 1/np.square(np.cos(self.x.data))
+        self.dx = grad * (1/np.square(np.cos(self.x.data)))
         #######################################################################
         # --------------------------- END OF YOUR CODE ------------------------
         #######################################################################
-- 
GitLab