arange

dragon.arange(
  start,
  stop=None,
  step=1,
  dtype='int64',
  **kwargs
)[source]

Return a tensor with evenly spaced values within a interval.

Specify start and stop to determine an interval:

x = dragon.arange(2, 4)  # [2, 3]

If stop is None, interval \([0, start)\) will be taken instead:

x = dragon.arange(5)  # [0, 1, 2, 3, 4]

Set step to make the strides:

x = dragon.arange(5, step=2)  # [0, 2, 4]
Parameters:
  • start (number) – The start of interval.
  • stop (number, optional) – The end of interval.
  • step (number, optional, default=1) – The spacing between two elements.
  • dtype (str, optional, default='int64') – The optional data type.
Returns:

dragon.Tensor – The output tensor.