Convert a float number to float tensor with 100% precision

Hi
I have an excel file that contains float numbers like the below:
-4.787870188
-3.50905703
(the length of them is 15 or 17)

But when I want to convert them to tensor, it will be rounded like this:
(tensor([-4.7879])
(tensor([-3.5091])

Is there a way to convert the original numbers into the tensor with their actual precisions?

Hi @jahanifar,

This is most likely due to the print options settings in pytorch (docs here)

Can you set torch.set_printoptions(precision=10) (just after you import torch) and re-run this? You’ll get the correct values. If not, use torch.float64 instead!

1 Like