From b29900f63533f77c594a4c032492c89a4a688055 Mon Sep 17 00:00:00 2001 From: SsnL Date: Fri, 27 Apr 2018 02:40:25 +0800 Subject: [PATCH] Update migration guide on new constraints of module/buffer/parameter names --- _posts/2018-04-22-0_4_0-migration-guide.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_posts/2018-04-22-0_4_0-migration-guide.md b/_posts/2018-04-22-0_4_0-migration-guide.md index 8c3cda0bb14e..d6c475c6d23d 100644 --- a/_posts/2018-04-22-0_4_0-migration-guide.md +++ b/_posts/2018-04-22-0_4_0-migration-guide.md @@ -11,6 +11,7 @@ Welcome to the migration guide for PyTorch 0.4.0. In this release we introduced * Deprecation of the ``volatile`` flag * ``dtypes``, ``devices``, and Numpy-style ``Tensor`` creation functions * Writing device-agnostic code +* New edge-case constraints on names of submodules, parameters, and buffers in ``nn.Module`` ## Merging [``Tensor``](http://pytorch.org/docs/0.4.0/tensors.html) and ``Variable`` and classes @@ -299,6 +300,10 @@ input = data.to(device) model = MyModule(...).to(device) ``` +## New edge-case constraints on names of submodules, parameters, and buffers in ``nn.Module`` + +`name` that is an empty string or contains `"."` is no longer permitted in `module.add_module(name, value)`, `module.add_parameter(name, value)` or `module.add_buffer(name, value)` because such names may cause lost data in the `state_dict`. If you are loading a checkpoint for modules containing such names, please update the module definition and patch the `state_dict` before loading it. + ## Code Samples (Putting it all together) To get a flavor of the overall recommended changes in 0.4.0, let's look at a quick example for a common code pattern in both 0.3.1 and 0.4.0: