mindspore.ops.LinSpace
- class mindspore.ops.LinSpace[源代码]
Returns a Tensor whose value is num evenly spaced in the interval start and stop (including start and stop), and the length of the output Tensor is num.
\[\begin{split}\begin{aligned} &step = (stop - start)/(num - 1)\\ &output = [start, start+step, start+2*step, ... , stop] \end{aligned}\end{split}\]- Inputs:
start (Tensor) - The data type must be float32. Start value of interval, With shape of 0-D.
stop (Tensor) - The data type must be float32. Last value of interval, With shape of 0-D.
num (int) - Number of ticks in the interval, inclusive of start and stop.
- Outputs:
Tensor, has the same shape and dtype as start.
- Raises
- Supported Platforms:
Ascend
GPU
Examples
>>> linspace = ops.LinSpace() >>> start = Tensor(1, mindspore.float32) >>> stop = Tensor(10, mindspore.float32) >>> num = 5 >>> output = linspace(start, stop, num) >>> print(output) [ 1. 3.25 5.5 7.75 10. ]