Does 1. == 1.0 in numpy and pytorch?

60 views Asked by At

The output of methods such as

a=torch.ones(1,4)

is

tensor([[1., 1., 1., 1.]])

Does the number '1.' is the abbreviation of '1.0', or it is exactly the same as integer '1'?

Sorry to ask such a simple question because I don't know which key words are appropriate to search in offical documentation.

1

There are 1 answers

0
TheHungryCub On

In PyTorch, the number '1.' is equivalent to '1.0', which is a floating-point number.

So, it's not the same as the integer '1'. In the tensor you provided, the numbers are represented as floating-point numbers with one decimal point, not integers.