Skip to content

The ELU activation is added #8699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tanh function is added
  • Loading branch information
TMGA-WAY committed Apr 23, 2023
commit d42af7b70f5315589c687219cb0b781db5b51375
12 changes: 8 additions & 4 deletions maths/tanh.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"""
import numpy
import numpy as np
import doctest


def tanh_func(vector):
def tanh_func(vector: np.array) -> np.array:
"""
Implements the tanh function

Parameters:
vector: np.array, list, tuple consisting real values
vector: np.array

Returns:
tanh (np.array): The input numpy array after applying
Expand All @@ -26,12 +27,15 @@ def tanh_func(vector):

Examples:
>>> tanh_func(np.array([1, 5, 6, 113, 13, 16, -5.23]))
[ 0.76159416 0.9999092 0.99998771 1. 1. 1. -0.99994268]
array([ 0.76159416, 0.9999092 , 0.99998771, 1. , 1. ,
1. , -0.99994268])

"""

exp_vector = np.exp(-2 * vector)
return (2 / (1 + exp_vector)) - 1


if __name__ == '__main__':
print(tanh_func(np.array([0.23])))
doctest.testmod()