MCPcopy Create free account
hub / github.com/SooLab/CGFormer / gelu_new

Function gelu_new

bert/activations.py:25–29  ·  view source on GitHub ↗

Implementation of the gelu activation function currently in Google Bert repo (identical to OpenAI GPT). Also see https://arxiv.org/abs/1606.08415

(x)

Source from the content-addressed store, hash-verified

23
24
25def gelu_new(x):
26 """ Implementation of the gelu activation function currently in Google Bert repo (identical to OpenAI GPT).
27 Also see https://arxiv.org/abs/1606.08415
28 """
29 return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * torch.pow(x, 3.0))))
30
31
32if torch.__version__ < "1.4.0":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected