mindspore.ops.linspace

View Source On Gitee
mindspore.ops.linspace(start, end, steps)[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]
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.]