From ea73f1c9e6301142c21fc00f9c5743d4b1380dcd Mon Sep 17 00:00:00 2001 From: Anish Singh Date: Tue, 3 Nov 2026 00:21:10 +0530 Subject: [PATCH] Add model.eval() after loading model in saveloadrun_tutorial (fixes #3965) Ensures consistency with the earlier loading pattern in this tutorial by placing the model into evaluation mode for inference. --- beginner_source/basics/saveloadrun_tutorial.py | 1 + 1 file changed, 1 insertion(+) diff --git a/beginner_source/basics/saveloadrun_tutorial.py b/beginner_source/basics/saveloadrun_tutorial.py index e80d32a6eaa..8683335baf9 100644 --- a/beginner_source/basics/saveloadrun_tutorial.py +++ b/beginner_source/basics/saveloadrun_tutorial.py @@ -63,6 +63,7 @@ # model, which is a legacy use case for ``torch.save``. model = torch.load('model.pth', weights_only=False) +model.eval() ######################## # .. note:: This approach uses Python `pickle `_ module when serializing the model, thus it relies on the actual class definition to be available when loading the model.