Skip to content

torch.range is upper-bound inclusive, while python range and numpy arange are upper-bound exclusive #733

@stefbraun

Description

@stefbraun

torch.range(a,b) includes b, while python.range(a,b) or numpy.arange(a,b) do not include b.
Not sure if this is a bug or voluntary, but this is confusing.

pytorch

In: torch.range(0,5)
Out: 0 1 2 3 4 5 [torch.FloatTensor of size 6]

python standard function

In: range(0,5)
Out: [0, 1, 2, 3, 4]

numpy

In: np.arange(0,5)
Out: array([0, 1, 2, 3, 4])

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions