Skip to content

Commit 1fe4025

Browse files
authored
Set the random seed for reproducibility of the output (#2428)
We also fix the code to use the scripted_cell just created. Fixes #1449 Signed-off-by: BJ Hargrave <[email protected]>
1 parent 3b6d83b commit 1fe4025

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

beginner_source/Intro_to_TorchScript_tutorial.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import torch # This is all you need to use both PyTorch and TorchScript!
3535
print(torch.__version__)
36+
torch.manual_seed(191009) # set the seed for reproducibility
3637

3738

3839
######################################################################
@@ -308,7 +309,7 @@ def forward(self, x, h):
308309

309310
# New inputs
310311
x, h = torch.rand(3, 4), torch.rand(3, 4)
311-
traced_cell(x, h)
312+
print(scripted_cell(x, h))
312313

313314

314315
######################################################################

0 commit comments

Comments
 (0)