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

Method testGradient

tensorflow/python/kernel_tests/gelu_op_test.py:57–70  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
72if __name__ == "__main__":
73 test.main()

Callers

nothing calls this directly

Calls 3

cached_sessionMethod · 0.45
constantMethod · 0.45
geluMethod · 0.45

Tested by

no test coverage detected