Implement the Tanh (Hyperbolic Tangent) activation function. Tanh squashes values to the range (-1, 1) and is symmetric around zero.
Tanh Formula:
tanh(x)=ex+e−xex−e−xx - Input (scalar, list, or NumPy array)Input: [0, 1, -1, 3]
Output: [0.0, 0.7616, -0.7616, 0.9951]
Symmetric around zero, bounded between -1 and 1
Input: 0.0
Output: [0.0]
Scalar input returns 1D array with shape (1)
Input: [[0, 1], [-1, 2]]
Output: [[0.0, 0.7616], [-0.7616, 0.9640]]
Works element-wise on multi-dimensional arrays
np.ndarray of floatsSign in to take notes on this problem
Accepts: array
Implement the Tanh (Hyperbolic Tangent) activation function. Tanh squashes values to the range (-1, 1) and is symmetric around zero.
Tanh Formula:
tanh(x)=ex+e−xex−e−xx - Input (scalar, list, or NumPy array)Input: [0, 1, -1, 3]
Output: [0.0, 0.7616, -0.7616, 0.9951]
Symmetric around zero, bounded between -1 and 1
Input: 0.0
Output: [0.0]
Scalar input returns 1D array with shape (1)
Input: [[0, 1], [-1, 2]]
Output: [[0.0, 0.7616], [-0.7616, 0.9640]]
Works element-wise on multi-dimensional arrays
np.ndarray of floatsSign in to take notes on this problem
Accepts: array