MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / assertTensorClose

Method assertTensorClose

lib/nn/modules/unittest.py:24–29  ·  view source on GitHub ↗
(self, a, b, atol=1e-3, rtol=1e-3)

Source from the content-addressed store, hash-verified

22
23class TorchTestCase(unittest.TestCase):
24 def assertTensorClose(self, a, b, atol=1e-3, rtol=1e-3):
25 npa, npb = as_numpy(a), as_numpy(b)
26 self.assertTrue(
27 np.allclose(npa, npb, atol=atol),
28 'Tensor close check failed\n{}\n{}\nadiff={}, rdiff={}'.format(a, b, np.abs(npa - npb).max(), np.abs((npa - npb) / np.fmax(npa, 1e-5)).max())
29 )

Callers 2

testNumericBatchNormMethod · 0.80
_checkBatchNormResultMethod · 0.80

Calls 1

as_numpyFunction · 0.70

Tested by

no test coverage detected