Solved by ptrblck in post #2 
              
              
                Stick to the second approach, as the first one is deprecated and might yield unwanted side effects. 
In a torch.no_grad() block all new operations won’t be tracked. The requires_grad attribute of your parameters will not be changed: 
model = models.resnet50()

with torch.no_grad():
    print(model.f…