Skip to content

Update migration guide on new constraints of module/buffer/parameter names #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2018
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
5 changes: 5 additions & 0 deletions _posts/2018-04-22-0_4_0-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down