UserWarning: volatile was removed and now has no essfet. Use 'with torch.no_grad():' insted

115 Views Asked by At

The version of PyTorch: 1.4.0+cu100 When running

val_L= Variable(torch.from_numpy(val_L.copy()), volatile=True).cuda()

occurred:

UserWarning: volatile was removed and now has no essfet. Use 'with torch.no_grad():' insted.

So, how should I modify the code? Thank you very much!!!

1

There are 1 best solutions below

1
Prajot Kuvalekar On

this is what it is referring to

with torch.no_grad():
    val_L= Variable(torch.from_numpy(val_L.copy()))