Compute the exact Gaussian Error Linear Unit for every input value:
GELU(x)=2x(1+erf(2x))Here, x is an input value and erf is the Gaussian error function. Apply the formula elementwise and return a NumPy array with the same shape as the input.
Input: x = [-1.0, 0.0, 1.0]
Output: [-0.158655, 0.0, 0.841345]
Explanation: The exact GELU formula scales negative values toward zero while retaining most of a positive value.
Input: x = [[-2.0, -1.0], [0.0, 1.0]]
Output: [[-0.0455, -0.158655], [0.0, 0.841345]]
Use np.asarray(x, dtype=float) before applying the formula.
Use np.vectorize(math.erf) to apply the scalar error function elementwise.
Sign in to take notes on this problem
Accepts: array
Compute the exact Gaussian Error Linear Unit for every input value:
GELU(x)=2x(1+erf(2x))Here, x is an input value and erf is the Gaussian error function. Apply the formula elementwise and return a NumPy array with the same shape as the input.
Input: x = [-1.0, 0.0, 1.0]
Output: [-0.158655, 0.0, 0.841345]
Explanation: The exact GELU formula scales negative values toward zero while retaining most of a positive value.
Input: x = [[-2.0, -1.0], [0.0, 1.0]]
Output: [[-0.0455, -0.158655], [0.0, 0.841345]]
Use np.asarray(x, dtype=float) before applying the formula.
Use np.vectorize(math.erf) to apply the scalar error function elementwise.
Sign in to take notes on this problem
Accepts: array