When I try to create a tensor using torch.empty() i get the following:
>>> torch.empty(5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/diego/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 57, in __repr__
return torch._tensor_str._str(self)
File "/home/diego/anaconda3/lib/python3.6/site-packages/torch/_tensor_str.py", line 218, in _str
fmt, scale, sz = _number_format(self)
File "/home/diego/anaconda3/lib/python3.6/site-packages/torch/_tensor_str.py", line 96, in _number_format
if value != math.ceil(value.item()):
RuntimeError: Overflow when unpacking long
And yes, that is correct. You can apply operations but canât print the value.
This happens because torch.empty initializes your tensor with âun-initializedâ data. Some of this data happened to have very, very large float values. The tensor printing code attempts to convert this number to an int (to see if it would be better printed as an integer), causing an overflow because there is a limit on how large a python int/long can be.
from future import print_function import torch x = torch.empty(5, 3) print(x)
Generates the following:
AttributeError: module âtorchâ has no attribute âemptyâ
I got a series of other errors early on in the tutorial as well:
x = torch.zeros(5, 3, dtype=torch.long)
AttributeError: module âtorchâ has no attribute âlongâ
x = torch.tensor([5.5, 3])
Only works with torch.Tensor([5.5, 3]) (capitalized)
Iâm using a fresh installation of PyTorch for a fastai course â have posted there to see if theyâre using a modified or old version. They seem really enthusiastic and dedicated to PyTorch (and recommend the tutorial), so I was surprised at the many immediate problems. Any advice much appreciated.