I'm using Google Colab and when I run the following code:
from torch import tensor, arange
print( arange(0.0, 1.2, 0.2) )
print( arange(tensor(0.0), tensor(1.2), tensor(0.2)) )
I get the output:
tensor([0.0000, 0.2000, 0.4000, 0.6000, 0.8000, 1.0000])
tensor([0.0000, 0.2000, 0.4000, 0.6000, 0.8000, 1.0000, 1.2000])
This discrepancy also occurs with arange(0.0,1.1,0.1) but there is no discrepancy with arange(0.0,1.5,0.5).
Why does seemingly similar code give different results, and how can I anticipate when this will occur?