What am I missing here?

I simply want to run this command on google colab

x = torch.Tensor([51,2,3,4,5])
print(x)

and the output is

TypeError Traceback (most recent call last)
in ()
----> 1 x = torch.tensor([51,2,3,4,5])
2 print(x)

TypeError: ‘module’ object is not callable

Could anyone tell me what is going wrong here? This is literally the first line of the tutorials as given on this page
http://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py

Which PyTorch version did you install on Google Colab?
From the error message it looks like you called

x = torch.tensor([51, 2, 3, 4, 5])

(lowercase t in tensor)

This call is available since version 0.4.0.
In previous versions you had to use the Tensor class (uppercase T).

Could you try that?

1 Like