Skip to content

Commit 9391f96

Browse files
committed
# Fix 2 incorrect argument positioning
1. "weights_only" is augument of torch.load, not for model.load_state_dict Here is the doc: https://pytorch.org/docs/stable/generated/torch.load.html
1 parent 23a9aa0 commit 9391f96

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

beginner_source/saving_loading_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
# .. code:: python
154154
#
155155
# model = TheModelClass(*args, **kwargs)
156-
# model.load_state_dict(torch.load(PATH), weights_only=True)
156+
# model.load_state_dict(torch.load(PATH, weights_only=True))
157157
# model.eval()
158158
#
159159
# .. note::
@@ -407,7 +407,7 @@
407407
# .. code:: python
408408
#
409409
# modelB = TheModelBClass(*args, **kwargs)
410-
# modelB.load_state_dict(torch.load(PATH), strict=False, weights_only=True)
410+
# modelB.load_state_dict(torch.load(PATH, weights_only=True), strict=False)
411411
#
412412
# Partially loading a model or loading a partial model are common
413413
# scenarios when transfer learning or training a new complex model.

0 commit comments

Comments
 (0)