Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions beginner_source/saving_loading_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@
# ``load_state_dict()`` function. For example, you CANNOT load using
# ``model.load_state_dict(PATH)``.
#
# .. Note ::
#
# If you only plan to keep the best performing model (according to the
# acquired validation loss), don't forget that ``best_model_state = model.state_dict()``
# returns a reference to the state and not its copy! You must serialize
# ``best_model_state`` or use ``best_model_state = deepcopy(model.state_dict())`` otherwise
# your best ``best_model_state`` will keep getting updated by the subsequent training
# iterations. As a result, the final model state will be the state of the overfitted model.
#
# Save/Load Entire Model
# ^^^^^^^^^^^^^^^^^^^^^^
Expand Down