From 75304d4a703057c2913b30b87d341cfd0920652c Mon Sep 17 00:00:00 2001 From: Mickus Timothee Date: Fri, 22 Sep 2023 17:59:43 +0300 Subject: [PATCH] undo forward-hook side-effect --- onmt/trainer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/onmt/trainer.py b/onmt/trainer.py index f0fa8efd..8d210df3 100644 --- a/onmt/trainer.py +++ b/onmt/trainer.py @@ -447,6 +447,10 @@ def validate(self, valid_iter, moving_average=None, task=None): # Set model back to training mode. valid_model.train() + for p in self.model.parameters(): + if hasattr(p, 'has_grad'): + p.has_grad = False + return stats def _gradient_accumulation_over_lang_pairs(