From d34143875fd57eae117b5054ac1cb110e3bf7bab Mon Sep 17 00:00:00 2001 From: Falguni Ghosh <falguni.ghosh@fau.de> Date: Sun, 15 Oct 2023 21:16:22 +0000 Subject: [PATCH] Upload New File --- 3_RNN/TanH.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 3_RNN/TanH.py diff --git a/3_RNN/TanH.py b/3_RNN/TanH.py new file mode 100644 index 0000000..a1de7cf --- /dev/null +++ b/3_RNN/TanH.py @@ -0,0 +1,22 @@ +import numpy as np +from .Base import BaseLayer + + +class TanH(BaseLayer): + + def __init__(self): + super().__init__() + self.activation = None + self.error_tensor = None + + def forward(self,input_tensor): + + self.activation = np.tanh(input_tensor) + + return self.activation + + def backward(self,error_tensor): + + self.error_tensor = error_tensor * (1-self.activation**2) + + return self.error_tensor -- GitLab