Skip to content

Instantly share code, notes, and snippets.

@khanhnamle1994
Last active May 22, 2018 02:36
Show Gist options
  • Save khanhnamle1994/c7c916db1b2389b838ed7a8038b1d66f to your computer and use it in GitHub Desktop.
Save khanhnamle1994/c7c916db1b2389b838ed7a8038b1d66f to your computer and use it in GitHub Desktop.
Tanh Activation Function
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