Skip to content

Commit 90f4771

Browse files
author
Jessica Lin
authored
Merge pull request #1036 from jamesr66a/save_note
Add note about zipfile format in serialization tutorial
2 parents 28f044e + 4e97bce commit 90f4771

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ All the tutorials are now presented as sphinx style documentation at:
1111

1212
We use sphinx-gallery's [notebook styled examples](https://sphinx-gallery.github.io/stable/tutorials/index.html) to create the tutorials. Syntax is very simple. In essence, you write a slightly well formatted python file and it shows up as documentation page.
1313

14-
Here's how to create a new tutorial:
14+
Here's how to create a new tutorial or recipe:
1515
1. Create a notebook styled python file. If you want it executed while inserted into documentation, save the file with suffix `tutorial` so that file name is `your_tutorial.py`.
16-
2. Put it in one of the beginner_source, intermediate_source, advanced_source based on the level.
17-
2. Include it in the right TOC tree at index.rst
18-
3. Create a thumbnail in the index file using a command like `.. galleryitem:: beginner/your_tutorial.py`. (This is a custom directive. See `custom_directives.py` for more info.)
16+
2. Put it in one of the beginner_source, intermediate_source, advanced_source based on the level. If it is a recipe, add to recipes_source.
17+
2. For Tutorials, include it in the TOC tree at index.rst
18+
3. For Tutorials, create a thumbnail in the [index.rst file](https://github.com/pytorch/tutorials/blob/master/index.rst) using a command like `.. customcarditem:: beginner/your_tutorial.html`. For Recipes, create a thumbnail in the [recipes_index.rst](https://github.com/pytorch/tutorials/blob/master/recipes_source/recipes_index.rst)
1919

2020
In case you prefer to write your tutorial in jupyter, you can use [this script](https://gist.github.com/chsasank/7218ca16f8d022e02a9c0deb94a310fe) to convert the notebook to python file. After conversion and addition to the project, please make sure the sections headings etc are in logical order.
2121

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)