mindspore.mint.linspace

View Source On Gitee
mindspore.mint.linspace(start, end, steps, *, dtype=None)[source]

Generate a one-dimensional tensor with steps elements, evenly distributed in the interval [start, end].

step=(endstart)/(steps1)output=[start,start+step,start+2step,...,end]

Warning

Atlas training series does not support int16 dtype currently.

Parameters
  • start (Union[float, int]) – Start value of interval.

  • end (Union[float, int]) – Last value of interval.

  • steps (int) – Number of elements.

Keyword Arguments

dtype (mindspore.dtype, optional) – The data type returned.

Returns

Tensor

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> output = mindspore.mint.linspace(3, 10, 5)
>>> print(output)
[ 3.    4.75  6.5   8.25 10.  ]
>>> output = mindspore.mint.linspace(-10, 10, 5)
>>> print(output)
[-10.  -5.   0.   5.  10.]
>>> output = mindspore.mint.linspace(-10, 10, 1)
>>> print(output)
[-10.]