MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / gelu

Method gelu

tensorflow/python/ops/nn_test.py:1025–1031  ·  view source on GitHub ↗
(x, approximate=False)

Source from the content-addressed store, hash-verified

1023 def test(self):
1024
1025 def gelu(x, approximate=False):
1026 if approximate:
1027 return 0.5 * x * (1.0 + np.tanh(np.sqrt(2.0 / np.pi) *
1028 (x + 0.044715 * np.power(x, 3))))
1029 else:
1030 from scipy.stats import norm # pylint: disable=g-import-not-at-top
1031 return x * norm.cdf(x)
1032
1033 np.random.seed(1) # Make it reproducible.
1034 x = np.random.randn(3, 4).astype(np.float32)

Callers 2

testMethod · 0.45
geluFunction · 0.45

Calls 2

powerMethod · 0.80
cdfMethod · 0.45

Tested by

no test coverage detected