linspace

dragon.vm.torch.linspace(
  start,
  end,
  steps=100,
  out=None,
  dtype='int64',
  dim=0,
  device=None,
  requires_grad=False
)[source]

Generate evenly spaced values within intervals along the given axis.

Interval \([\text{start}, \text{end})\) is determined for steps values:

x = torch.linspace(2, 4, steps=3)  # [2, 3, 4]

More than one intervals are accepted to generate N-d coordinates:

x = torch.linspace([1, 2], [3, 4], steps=3, dim=0)  # [[1, 2], [2, 3], [3, 4]]
y = torch.linspace([1, 2], [3, 4], steps=3, dim=1)  # [[1, 2, 3], [2, 3, 4]]
Parameters:
  • start (Union[number, Sequence[number]]) – The start(s) of interval.
  • end (Union[number, Sequence[number]]) – The ends(s) of interval.
  • steps (int, optional, default=100) – The number of values to generate.
  • out (dragon.vm.torch.Tensor, optional) – The optional output tensor.
  • dtype (str, optional, default='int64') – The optional data type.
  • dim (int, optional, default=0) – The dimension to generate values.
  • 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 – The output tensor.