Apply the hyperbolic tangent activation elementwise:
tanh(x)=ex+e−xex−e−xHere, x is each input value. Return a NumPy array with the same shape as the input and values in (−1,1).
Input: x = [0, 1, -1, 3]
Output: [0.0, 0.761594, -0.761594, 0.995055]
Explanation: Tanh maps zero to zero and maps positive and negative inputs symmetrically toward 1 and -1.
Input: x = [[0, 1], [-1, 2]]
Output: [[0.0, 0.761594], [-0.761594, 0.964028]]
Convert the input with np.asarray(x, dtype=float).
Use NumPy's vectorized np.tanh function.
Sign in to take notes on this problem
Accepts: array
Apply the hyperbolic tangent activation elementwise:
tanh(x)=ex+e−xex−e−xHere, x is each input value. Return a NumPy array with the same shape as the input and values in (−1,1).
Input: x = [0, 1, -1, 3]
Output: [0.0, 0.761594, -0.761594, 0.995055]
Explanation: Tanh maps zero to zero and maps positive and negative inputs symmetrically toward 1 and -1.
Input: x = [[0, 1], [-1, 2]]
Output: [[0.0, 0.761594], [-0.761594, 0.964028]]
Convert the input with np.asarray(x, dtype=float).
Use NumPy's vectorized np.tanh function.
Sign in to take notes on this problem
Accepts: array