Skip to content

Commit 4e97bce

Browse files
author
James Reed
committed
Add note about zipfile format in serialization tutorial
1 parent d40dc05 commit 4e97bce

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

beginner_source/saving_loading_models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@
156156
# model.load_state_dict(torch.load(PATH))
157157
# model.eval()
158158
#
159+
# .. note::
160+
# The 1.6 release of PyTorch switched ``torch.save`` to use a new
161+
# zipfile-based file format. ``torch.load`` still retains the ability to
162+
# load files in the old format. If for any reason you want ``torch.save``
163+
# to use the old format, pass the kwarg ``_use_new_zipfile_serialization=False``.
164+
#
159165
# When saving a model for inference, it is only necessary to save the
160166
# trained model’s learned parameters. Saving the model’s *state_dict* with
161167
# the ``torch.save()`` function will give you the most flexibility for

0 commit comments

Comments
 (0)