我想把我的一些模型冻结.遵循官方文档:
with torch.no_grad(): linear = nn.Linear(1, 1) linear.eval() print(linear.weight.requires_grad)
但它打印True而不是False.如果我想在eval模式下设置模型,我该怎么办?
True
False
python gradient-descent pytorch
gradient-descent ×1
python ×1
pytorch ×1