(self, x, approximate=False)
| 31 | class GeluTest(test.TestCase): |
| 32 | |
| 33 | def _npGelu(self, x, approximate=False): |
| 34 | if approximate: |
| 35 | return 0.5 * x * (1.0 + np.tanh(np.sqrt(2.0 / np.pi) * |
| 36 | (x + 0.044715 * np.power(x, 3)))) |
| 37 | else: |
| 38 | from scipy.stats import norm # pylint: disable=g-import-not-at-top |
| 39 | return x * norm.cdf(x) |
| 40 | |
| 41 | def _testGelu(self, np_features, approximate=False, use_gpu=False): |
| 42 | expected_values = self._npGelu(np_features, approximate) |