Last active
May 22, 2018 02:36
-
-
Save khanhnamle1994/c7c916db1b2389b838ed7a8038b1d66f to your computer and use it in GitHub Desktop.
Tanh Activation Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tanh: | |
def forward(self, x): | |
return np.tanh(x) | |
def backward(self, x, top_diff): | |
output = self.forward(x) | |
return (1.0 - np.square(output)) * top_diff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment