MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / gelu

Function gelu

examples/tensorflow/bert/bert-quantization/modeling.py:280–293  ·  view source on GitHub ↗

Gaussian Error Linear Unit. This is a smoother version of the RELU. Original paper: https://arxiv.org/abs/1606.08415 Args: x: float Tensor to perform activation. Returns: `x` with the GELU activation applied.

(x)

Source from the content-addressed store, hash-verified

278
279
280def gelu(x):
281 """Gaussian Error Linear Unit.
282
283 This is a smoother version of the RELU.
284 Original paper: https://arxiv.org/abs/1606.08415
285 Args:
286 x: float Tensor to perform activation.
287
288 Returns:
289 `x` with the GELU activation applied.
290 """
291 cdf = 0.5 * (1.0 + tf.tanh(
292 (np.sqrt(2 / np.pi) * (x + 0.044715 * tf.pow(x, 3)))))
293 return x * cdf
294
295
296def get_activation(activation_string):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected