volatile 被移除,现在没有效果。与 torch.no_grad(): 一起使用
volatile was removed and now has no effect. Use with torch.no_grad(): instead
我遇到了这个错误,你能帮帮我吗?
这是我在 utils.py 文件
中的错误
content/gdrive/My Drive/DeepFakeDetection/utils.py:21: UserWarning:
volatile was removed and now has no effect. Use with torch.no_grad():
instead. return Variable(x, volatile=volatile)
这是我在 utils.py 文件中的代码
def to_var(x, volatile=False):
if torch.cuda.is_available():
x = x.cuda()
return Variable(x, volatile=volatile)
谢谢
我改成了这样:
def to_var(x, volatile=False):
>
> with torch.no_grad():
>
> if torch.cuda.is_available():
> x = x.cuda()
> return x
我遇到了这个错误,你能帮帮我吗? 这是我在 utils.py 文件
中的错误 content/gdrive/My Drive/DeepFakeDetection/utils.py:21: UserWarning:
volatile was removed and now has no effect. Use with torch.no_grad():
instead. return Variable(x, volatile=volatile)
这是我在 utils.py 文件中的代码
def to_var(x, volatile=False):
if torch.cuda.is_available():
x = x.cuda()
return Variable(x, volatile=volatile)
谢谢
我改成了这样:
def to_var(x, volatile=False):
>
> with torch.no_grad():
>
> if torch.cuda.is_available():
> x = x.cuda()
> return x