From 8865c6b913c5241a6a0eabb820608de464955ff2 Mon Sep 17 00:00:00 2001 From: Edib Hamza Arslan <35764362+EdibHamzaArslan@users.noreply.github.com> Date: Sat, 13 Nov 2021 01:45:24 +0300 Subject: [PATCH] torch.no_grad is changed with torch.inference_mode torch.inference_mode is more faster than no_grad --- cycnn/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cycnn/main.py b/cycnn/main.py index 05ae9d5..a9540c3 100644 --- a/cycnn/main.py +++ b/cycnn/main.py @@ -70,7 +70,7 @@ def validate(model, device, criterion, test_loader, epoch, args): model.eval() validation_loss, correct, num_data = 0, 0, 0 - with torch.no_grad(): + with torch.inference_mode(): for batch_idx, (images, labels) in enumerate(test_loader): if args['dataset'] == 'svhn': @@ -122,7 +122,7 @@ def test(model, device, criterion, test_loader, args): model.eval() test_loss, correct, num_data = 0, 0, 0 - with torch.no_grad(): + with torch.inference_mode(): for batch_idx, (images, labels) in enumerate(test_loader): if args['dataset'] == 'svhn':