dave
(dave julian)
1
There apears to be an error in this tutorial… makes it really hard for beginners to learn!!
http://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html
Following intro tutorial and running
x = Variable(torch.ones(2, requires_grad=True))
print(x)
Gives:
TypeError Traceback (most recent call last)
in ()
----> 1 x = Variable(torch.ones(2, requires_grad=True))
2 print(x)
TypeError: torch.ones received an invalid combination of arguments - got (int, requires_grad=bool), but expected one of:
- (int … size)
didn’t match because some of the keywords were incorrect: requires_grad
- (torch.Size size)
What is going on?. I followed the example exactly.
Which version are you using?
Two days ago PYTorch 0.4.0
was released merging Variable
s with Tensor
s.
I cannot find the line of code you’ve posted:
x = Variable(torch.ones(2, requires_grad=True))
And in 0.4.0
you don’t have to use Variables
anymore.
You can find the install instructions on the website.
PS: I’ve edited the title to be a bit more clear.
dave
(dave julian)
3
Thanks for your reply
Yep, sorry the line in the tutorial is:
x = torch.ones(2, 2, requires_grad=True)
Still gives the same error though, I thought wrapping it in a Variable might help!
I will try updating
Cheers
dave
(dave julian)
4
Solved. Updated to pytorch 0.4 and it works!