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

Method test

tensorflow/python/ops/nn_test.py:1023–1041  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1021class GeluTest(test_lib.TestCase):
1022
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)
1035 y = gelu(x)
1036 z = self.evaluate(nn_ops.gelu(constant_op.constant(x)))
1037 self.assertAllClose(y, z)
1038
1039 y = gelu(x, True)
1040 z = self.evaluate(nn_ops.gelu(constant_op.constant(x), True))
1041 self.assertAllClose(y, z)
1042
1043
1044class CReluTest(test_lib.TestCase):

Callers 1

test_image_generatorFunction · 0.45

Calls 6

geluFunction · 0.70
seedMethod · 0.45
evaluateMethod · 0.45
geluMethod · 0.45
constantMethod · 0.45
assertAllCloseMethod · 0.45

Tested by

no test coverage detected