range¶
- paddle.fluid.layers.tensor. range ( start, end, step, dtype, name=None ) [source]
- 
         This OP returns a 1-D Tensor with spaced values within a given interval. Values are generated into the half-open interval [ start,end) with thestep. (the interval includingstartbut excludingend).If dtypeis float32 or float64, we advise adding a small epsilon toendto avoid floating point rounding errors when comparing againstend.- Parameters
- 
           - start (float|int|Tensor) – Start of interval. The interval includes this value. If - startis a Tensor, it is a 1-D Tensor with shape [1], with data type int32, int64, float32, float64.
- end (float|int|Tensor) – End of interval. The interval does not include this value. If - endis a Tensor, it is a 1-D Tensor with shape [1], with data type int32, int64, float32, float64.
- step (float|int|Tensor) – Spacing between values. For any out, it is the istance between two adjacent values, out[i+1] - out[i]. If - stepis a Tensor, it is a 1-D Tensor with shape [1], with data type int32, int64, float32, float64.
- dtype (str|np.dtype|core.VarDesc.VarType, optional) – The data type of the output tensor. Supported data types: int32, int64, float32, float64. 
- name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name. 
 
- Returns
- 
           
           - 
             A 1-D Tensor with values from the interval [
             start,end)
- 
             taken with common difference stepbeginning fromstart. Its data type is set bydtype.
 
- 
             A 1-D Tensor with values from the interval [
             
- Return type
- 
           Tensor 
- Raises
- 
           TypeError – If dtypeis not int32, int64, float32, float64.
 Examples import paddle.fluid as fluid out1 = fluid.layers.range(0, 10, 2, 'int32') # [0, 2, 4, 6, 8] start_var = fluid.layers.fill_constant([1], 'int64', 3) out2 = fluid.layers.range(start_var, 7, 1, 'int64') # [3, 4, 5, 6] 
