arange¶
- paddle. arange ( start=0, end=None, step=1, dtype=None, name=None ) [source]
- 
         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 - endis None, the half-open interval is [0,- start). If- startis a Tensor, it is a 1-D Tensor with shape [1], with data type int32, int64, float32, float64. Default is 0.
- end (float|int|Tensor, optional) – 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. If- endis None, the half-open interval is [0,- start). Default is None.
- step (float|int|Tensor, optional) – 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. Default is 1.
- dtype (str|np.dtype, optional) – The data type of the output tensor. Supported data types: int32, int64, float32, float64. If - dytpeis None, the data type is float32. Default is None.
- name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None. 
 
- Returns
- 
           A 1-D Tensor with values from the interval [ start,end) taken with common differencestepbeginning fromstart. Its data type is set bydtype.
- Return type
- 
           Tensor 
 Examples import paddle out1 = paddle.arange(5) # [0, 1, 2, 3, 4] out2 = paddle.arange(3, 9, 2.0) # [3, 5, 7] # use 4.999 instead of 5.0 to avoid floating point rounding errors out3 = paddle.arange(4.999, dtype='float32') # [0., 1., 2., 3., 4.] start_var = paddle.to_tensor([3]) out4 = paddle.arange(start_var, 7) # [3, 4, 5, 6] 
