What to replace Variable(input , requires_grad=False) with?

I know in the new version of pytorch we dont need to wrap the input with variable anymore.
I am not sure what should i do if i have
Variable(input, requires_grad=False)
in my code though?

just use input.

if it is already tracking history and you want to stop that, use input.detach()

but if i just use the input wouldn’t the requires_grad consider to be true by default?
I mean if have
input1 = Variable(input1, requires_grad=False)
input2 = Variable(input2, requires_grad=True)
in the new version of pytorch, should i replace both of them with input1,input2 respectively?

by default requires_grad is false

input1 can be used as is. input2 should become input2.requires_grad_().

the migration guide explains this better! https://pytorch.org/2018/04/22/0_4_0-migration-guide.html

1 Like