About the behavior of Variable()

Hi there,

I am refactoring some legacy code. There is an expression:

x = tensor.zeros(10, 10)
y = Variable(x).cuda()

How to write the second line in a ‘modern’ way (compatible with pytorch > 1.0)?

Thanks!

Hi @phantom90

I suppose you can go with y = x.cuda() or y = x.to(device='cuda').

Please consider this migration guide

1 Like