Implement the Gaussian Error Linear Unit (GELU) activation function. It smoothly combines the behavior of linear and nonlinear activations by weighting each input x by the probability that a Gaussian random variable is less than x.
Input:
x = [-1.0, 0.0, 1.0]
Output:
[-0.158655, 0.0, 0.841345]
Input:
x = [[-2., -1.],[0., 1.]]
Output:
[[-0.045500, -0.158655],
[ 0.000000, 0.841345]]
Convert input to NumPy array first.
Use np.vectorize(math.erf) to make the error function work with arrays.
Sign in to take notes on this problem
Accepts: array
Implement the Gaussian Error Linear Unit (GELU) activation function. It smoothly combines the behavior of linear and nonlinear activations by weighting each input x by the probability that a Gaussian random variable is less than x.
Input:
x = [-1.0, 0.0, 1.0]
Output:
[-0.158655, 0.0, 0.841345]
Input:
x = [[-2., -1.],[0., 1.]]
Output:
[[-0.045500, -0.158655],
[ 0.000000, 0.841345]]
Convert input to NumPy array first.
Use np.vectorize(math.erf) to make the error function work with arrays.
Sign in to take notes on this problem
Accepts: array