arange

dragon.vm.torch.arange(
  start,
  end=None,
  step=1,
  out=None,
  dtype='int64',
  device=None,
  requires_grad=False
)[source]

Return a tensor with evenly spaced values within a interval.

Specify start and end to determine an interval:

print(torch.arange(2, 4))  # [2, 3]

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

print(torch.arange(5))  # [0, 1, 2, 3, 4]

Set delta to make the strides:

print(torch.arange(5, step=2))  # [0, 2, 4]
Parameters:
  • start (number) – The start of interval.
  • end (number, optional, default=0) – The stop of interval.
  • step (number, optional, default=1) – The spacing between two elements.
  • out (dragon.vm.torch.Tensor, optional) – The optional output tensor.
  • dtype (str, optional, default='int64') – The optional data type.
  • device (dragon.vm.torch.device, optional) – The optional device of returned tensor.
  • requires_grad (bool, optional, default=False) – True to record gradient for returned tensor.
Returns:

dragon.vm.torch.Tensor – A vector with evenly spaced elements.