PyTorch UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` inst

PyTorch UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.

flyfish

torch.autograd.Variable(inputs, volatile=True)

Variables in the new version of PyTorch has been deprecated

#old codes
...
x = Variable(torch.randn(1), volatile=True)
return x

#new codes
with torch.no_grad():
    ...
    x = torch.randn(1)
return x

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *