(self)
| 55 | approximate, use_gpu=True) |
| 56 | |
| 57 | def testGradient(self): |
| 58 | with self.cached_session(): |
| 59 | for approximate in [False, True]: |
| 60 | x = constant_op.constant( |
| 61 | [-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9], |
| 62 | shape=[2, 5]) |
| 63 | theoretical, numerical = gradient_checker_v2.compute_gradient( |
| 64 | lambda a: nn_ops.gelu(a, approximate), [x]) |
| 65 | err = gradient_checker_v2.max_error( |
| 66 | *gradient_checker_v2.compute_gradient( |
| 67 | lambda a: nn_ops.gelu(a, approximate), [x])) |
| 68 | |
| 69 | print("gelu (float32) gradient err = ", err) |
| 70 | self.assertLess(err, 1e-4) |
| 71 | |
| 72 | if __name__ == "__main__": |
| 73 | test.main() |
nothing calls this directly
no test coverage detected