Pytorch Data Value Inconsistencies

It’s a matter of print format

In [1]: import numpy as np

In [2]: import torch

In [3]: a = torch.ones(1)

In [4]: b = a+0.1

In [5]: b[0] == b.numpy()[0]
Out[5]: True

In [6]: type(b[0])
Out[6]: float

In [7]: type(b.numpy()[0])
Out[7]: numpy.float32

In [8]: np.set_printoptions(precision=10)


In [9]: b.numpy()
Out[9]: array([ 1.1000000238], dtype=float32)

see?

1 Like