pytorch / pytorch/tutorials

[BUG] - Incorrect output on Parametrizations Tutorial when leave_parametrized=False

Open
#3,078 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

Add Link

https://pytorch.org/tutorials/intermediate/parametrizations.html

Describe the bug

The code sample has no bug but the example output is wrong. The "weight" from after remove_parametrizations(layer, "weight", leave_parametrized=False) should be same as that from "Before" but instead it is shown as that of"Parametrized". I was confused until I tried out the code. It does change it back to the weights from "Before".

Before:
Linear(in_features=3, out_features=3, bias=True)
Parameter containing:
tensor([[-0.3447, -0.3777, 0.5038],
[ 0.2042, 0.0153, 0.0781],
[-0.4640, -0.1928, 0.5558]], requires_grad=True)

Parametrized:
ParametrizedLinear(
in_features=3, out_features=3, bias=True
(parametrizations): ModuleDict(
(weight): ParametrizationList(
(0): Skew()
)
)
)
tensor([[ 0.0000, -0.3777, 0.5038],
[ 0.3777, 0.0000, 0.0781],
[-0.5038, -0.0781, 0.0000]], grad_fn=)

After. Same as Before:
Linear(in_features=3, out_features=3, bias=True)
Parameter containing:
tensor([[ 0.0000, -0.3777, 0.5038],
[ 0.0000, 0.0000, 0.0781],
[ 0.0000, 0.0000, 0.0000]], requires_grad=True)

image

Describe your environment

Does not matter because there is no bug. It is just the output from the tutorial page.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the parametrizations tutorial at the linked URL and compare the displayed output after remove_parametrizations(layer, "weight", leave_parametrized=False) with the behavior of the sample code. Update the incorrect example output so it matches the restored weights, then verify the tutorial renders the corrected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.