linspace¶
-
paddle.fluid.layers.
linspace
(start, stop, num, dtype)[source] This OP return fixed number of evenly spaced values within a given interval.
- Parameters
start (float|Variable) – The input
start
is start variable of range. It is a float scalar, or a tensor of shape [1] with input data type float32, float64.stop (float|Variable) – The input
stop
is start variable of range. It is a float scalar, or a tensor of shape [1] with input data type float32, float64.num (int|Variable) – The input
num
is given num of the sequence. It is an int scalar, or a tensor of shape [1] with type int32.dtype (string) – The data type of output tensor, it could be ‘float32’ and ‘float64’.
- Returns
The 1-D tensor with fixed number of evenly spaced values, the data shape of this tensor is \([num]\) . If the
num
is set 1, the output tensor just has the value with inputstart
.- Return type
Variable, the output data type will be float32, float64.
Examples
import paddle.fluid as fluid data = fluid.layers.linspace(0, 10, 5, 'float32') # [0.0, 2.5, 5.0, 7.5, 10.0] data = fluid.layers.linspace(0, 10, 1, 'float32') # [0.0]