From 6b1547a15b91bd05c7c1944035b1b06a923e362f Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Mon, 5 Jun 2023 18:29:27 -0400 Subject: [PATCH] Set the random seed for reproducibility of the output We also fix the code to use the scripted_cell just created. Fixes https://github.com/pytorch/tutorials/issues/1449 Signed-off-by: BJ Hargrave --- beginner_source/Intro_to_TorchScript_tutorial.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beginner_source/Intro_to_TorchScript_tutorial.py b/beginner_source/Intro_to_TorchScript_tutorial.py index d369c4fbf8..21ee32ff38 100644 --- a/beginner_source/Intro_to_TorchScript_tutorial.py +++ b/beginner_source/Intro_to_TorchScript_tutorial.py @@ -33,6 +33,7 @@ import torch # This is all you need to use both PyTorch and TorchScript! print(torch.__version__) +torch.manual_seed(191009) # set the seed for reproducibility ###################################################################### @@ -308,7 +309,7 @@ def forward(self, x, h): # New inputs x, h = torch.rand(3, 4), torch.rand(3, 4) -traced_cell(x, h) +print(scripted_cell(x, h)) ######################################################################