megengine.functional.linspace

linspace(start, stop, num, *, dtype='float32', device=None)[source]

Returns evenly spaced numbers over a specified interval.

Returns num evenly spaced samples, calculated over the interval [start, stop].

Parameters
  • start (Number) – the start of the interval.

  • stop (Number) – the end of the interval.

  • num (int) – number of values to generate.

Keyword Arguments
  • dtype (Tensor.dtype, optional) – output tensor data type. If dtype is not given, the data type is inferred from start and stop.

  • device (Tensor.device, optional) – device on which to place the created tensor.

Return type

Tensor

Returns

a one-dimensional tensor containing evenly spaced values.

See also

arange

Examples

>>> F.linspace(1, 10, 10)
Tensor([ 1.  2.  3.  4.  5.  6.  7.  8.  9. 10.], device=xpux:0)
>>> F.linspace(2., 3., 5)
Tensor([2.   2.25 2.5  2.75 3.  ], device=xpux:0)