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

Method gelu

tensorflow/python/keras/activations_test.py:106–112  ·  view source on GitHub ↗
(x, approximate=False)

Source from the content-addressed store, hash-verified

104
105 def test_gelu(self):
106 def gelu(x, approximate=False):
107 if approximate:
108 return 0.5 * x * (1.0 + np.tanh(np.sqrt(2.0 / np.pi) *
109 (x + 0.044715 * np.power(x, 3))))
110 else:
111 from scipy.stats import norm # pylint: disable=g-import-not-at-top
112 return x * norm.cdf(x)
113 x = keras.backend.placeholder(ndim=2)
114 f = keras.backend.function([x], [keras.activations.gelu(x)])
115 test_values = np.random.random((2, 5))

Callers 4

_testGeluMethod · 0.45
testGradientMethod · 0.45
geluFunction · 0.45
test_geluMethod · 0.45

Calls 2

powerMethod · 0.80
cdfMethod · 0.45

Tested by

no test coverage detected