딥러닝 프레임워크/PyTorch
PyTorch - UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
keepee
2019. 12. 19. 14:29
# pix2pixHD debugging
에러로그: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
pyTorch에서 volatile을 더이상 지원하지 않으므로, with torch.no_grad()를 대신 이용하라는 Warning이 떴다.
pytorch discuss에서 검색해 본 결과, before의 코드를 now의 코드로 고치면 된다고 한다.
# before
...
x = Variable(torch.randn(1), volatile=True)
return x
# now
with torch.no_grad():
...
x = torch.randn(1)
return x
출처: https://discuss.pytorch.org/t/volatile-now-has-no-effect-use-with-torch-no-grad-instead/26656/16