tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

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

Open lampuiho opened this issue 1 year ago • 2 comments

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=<SubBackward0>)

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.

lampuiho avatar Oct 06 '24 13:10 lampuiho

@lezcano any thoughts?

svekars avatar Oct 07 '24 15:10 svekars

what I don't quite understand is why do we get the wrong result. I thought the results were generated by running the scripts in the tutorial?

lezcano avatar Oct 08 '24 07:10 lezcano