megengine.functional.linspace

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

Returns evenly spaced numbers over a specified interval.

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

参数
  • start (Number) – the start of the interval.

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

  • num (int) – 将要产生的值的个数。

关键字参数
  • 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.

返回类型

Tensor

返回

a one-dimensional tensor containing evenly spaced values.

参见

arange

实际案例

>>> 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)