April 10, 2024, 8:27 p.m. | Super Kai (Kazuya Ito)

DEV Community dev.to

arange() can create the 1D tensor of zero or more integers or floating-point numbers as shown below:


*Memos:




  • arange() can be used only from torch but not from a tensor.

  • The 1st argument is start which is 0 by default.

  • The 2nd argument is end.

  • The 3rd argument is step which is 1 by default.

  • Setting only one argument sets 0 to start.

  • There is range() which is similar to arange() but range() is deprecated.



import torch

torch.arange(5)
# tensor([0, …

integers logspace memos normal numbers pytorch tensor torch

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US