Tanh Activation
EasyMachine LearningMathArray
Description
Given an array of numbers, apply the hyperbolic tangent activation tanh(x) = (e^x - e^-x) / (e^x + e^-x) to each element. Round each result to 4 decimal places.
Examples
Input:
[0,1,-1]Output:
[0,0.7616,-0.7616]Explanation:
Each value is squashed by the hyperbolic tangent into the open range from -1 to 1, with 0 staying at 0.
Input:
[2,-2]Output:
[0.964,-0.964]Explanation:
Each value is squashed by the hyperbolic tangent into the open range from -1 to 1, with 0 staying at 0.
Input:
[0]Output:
[0]Explanation:
Each value is squashed by the hyperbolic tangent into the open range from -1 to 1, with 0 staying at 0.
Constraints
- •
1 ≤ length ≤ 10⁴