From 145a2bf88dacf762b01117c63515b1e93251e891 Mon Sep 17 00:00:00 2001 From: Zymrael <34561392+Zymrael@users.noreply.github.com> Date: Mon, 24 Aug 2020 14:52:10 +0900 Subject: [PATCH] [tests] adjust tolerance of adjoint tests --- test/test_adjoint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_adjoint.py b/test/test_adjoint.py index fa08080..6942cef 100644 --- a/test/test_adjoint.py +++ b/test/test_adjoint.py @@ -36,7 +36,7 @@ def test_adjoint_autograd(): loss = nn.CrossEntropyLoss()(y_hat, y) loss.backward() bp_grad = torch.cat([p.grad.flatten() for p in model.parameters()]) - assert (torch.abs(bp_grad - adj_grad) <= 1e-4).all(), f'Gradient error: {torch.abs(bp_grad - adj_grad).sum()}' + assert (torch.abs(bp_grad - adj_grad) <= 1e-3).all(), f'Gradient error: {torch.abs(bp_grad - adj_grad).sum()}' @@ -74,4 +74,4 @@ def test_integral_adjoint_integral_autograd(): loss = loss.backward() g_adjoint= deepcopy(x.grad) - assert torch.abs(g_autograd - g_adjoint).norm(dim=1, p=2).mean() < 1e-4 \ No newline at end of file + assert torch.abs(g_autograd - g_adjoint).norm(dim=1, p=2).mean() < 1e-3