I want to set some of my model frozen. Following the official docs:
with torch.no_grad(): linear = nn.Linear(1, 1
This tutorial may help.
In short words, I think a good way for this question could be:
linear = nn.Linear(1,1) for param in linear.parameters(): param.requires_grad = False linear.eval() print(linear.weight.requires_grad)