Example #1
0
 def test_zero_grad_tape(self):
     try:
         check_numerics_callback.enable_check_numerics()
         x = constant_op.constant([-1, 0., 1.])
         with backprop.GradientTape() as tape:
             tape.watch(x)
             g = tape.gradient(math_ops.pow(x, 2), x)
         g = self.evaluate(g)
         self.assertAllClose([-2., 0., 2.], g)
     finally:
         check_numerics_callback.disable_check_numerics()
 def tearDown(self):
     check_numerics_callback.disable_check_numerics()
     super(CheckNumericsCallbackTest, self).tearDown()
 def testCallingDisableCheckNumericsWithoutEnablingFirstIsTolerated(self):
     check_numerics_callback.disable_check_numerics()
Example #4
0
 def tearDown(self):
     if os.path.isdir(self.dump_root):
         shutil.rmtree(self.dump_root, ignore_errors=True)
     check_numerics_callback.disable_check_numerics()
     dumping_callback.disable_dump_debug_info()
     super(DumpingCallbackTestBase, self).tearDown()