mindspore.ops.linspace

mindspore.ops.linspace(start, end, steps)[source]

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

\[\begin{split}\begin{aligned} &step = (end - start)/(steps - 1)\\ &output = [start, start+step, start+2*step, ... , end] \end{aligned}\end{split}\]

Warning

Starting after version 2.9.0, an optional keyword argument dtype will be added. The signature will change to mindspore.ops.linspace(start, end, steps, *, dtype=None). This change is backward-compatible; behavior is unchanged when dtype is not specified.

Parameters
Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

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