From 8578a141969720ec93b9bc172c8f20d0ef66ed16 Mon Sep 17 00:00:00 2001 From: Jordan Gong Date: Thu, 4 Mar 2021 13:29:07 +0800 Subject: Replace detach with no_grad in evaluation --- models/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/model.py b/models/model.py index 83b970a..7aff6c4 100644 --- a/models/model.py +++ b/models/model.py @@ -423,7 +423,8 @@ class Model: def _get_eval_sample(self, sample: dict[str, Union[list, torch.Tensor]]): label = sample.pop('label').item() clip = sample.pop('clip').to(self.device) - feature = self.rgb_pn(clip).detach() + with torch.no_grad(): + feature = self.rgb_pn(clip) return { **{'label': label}, **sample, -- cgit v1.2.3