arange

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

Return a tensor of evenly spaced values within an 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 output tensor.
  • dtype (str, optional, default='int64') The data type of output tensor.
  • device (dragon.vm.torch.device, optional) The device of output tensor.
  • requires_grad (bool, optional, default=False) Record gradient for output tensor or not.
Returns:

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