I got your confusion. The question this thread discussed is similar to you.
What you want is to set slices of layer.weight.requires_grad=False
, I think it should be done manually as mentioned in the link above.
And for .data
, we can use with torch.no_grad():
to avoid the unsafe mode.
1 Like