arange

paddle.fluid.layers.arange(start, end, step=1, dtype=None, name=None)[source]

Return evenly spaced values within a given interval. Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). :param start: Start of interval. The interval includes this value.

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.arange, line 5)

Unexpected indentation.

when start is Variable, it is a 1-D Tensor with shape [1].

System Message: WARNING/2 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.arange, line 6)

Block quote ends without a blank line; unexpected unindent.

Parameters
  • end (float32 | float64 | int32 | int64 | Variable) – End of interval. The interval does not include this value, except in some cases where step is not an integer and floating point round-off affects the length of out. When end is Variable, it is a 1-D Tensor with shape [1].

  • step (float32 | float64 | int32 | int64 | Variable) – Spacing between values. For any output out, this is the distance between two adjacent values, out[i+1] - out[i].

  • dtype (str|core.VarDesc.VarType) – the data type of the output tensor, can be float32, float64, int32, int64.

Returns: a 1-D Tensor which is evenly spaced values within a given interval. Its data type is set by dtype.

Return type: Variable .. rubric:: Examples

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/tensor.py:docstring of paddle.fluid.layers.arange, line 23)

Error in “code-block” directive: maximum 1 argument(s) allowed, 42 supplied.

.. code-block:: python
     import paddle.fluid as fluid
     # expected out put: [0, 2, 4, 6, 8]
     data = fluid.layers.arange(0, 10, 2, 'int32')
 #dygraph mode
     import paddle.fluid as fluid
     with fluid.dygraph.guard():
         x = fluid.layers.arange(0, 6, 2)
         # x: [0, 2, 4]
         # x dtype: float32