Have a question? Connect with the community at the TensorFlow Forum

# tf.range

Creates a sequence of numbers.

``````tf.range(limit, delta=1, dtype=None, name='range')
tf.range(start, limit, delta=1, dtype=None, name='range')
``````

Creates a sequence of numbers that begins at `start` and extends by increments of `delta` up to but not including `limit`.

The dtype of the resulting tensor is inferred from the inputs unless it is provided explicitly.

Like the Python builtin `range`, `start` defaults to 0, so that `range(n) = range(0, n)`.

#### For example:

``````start = 3
limit = 18
delta = 3
tf.range(start, limit, delta)  # [3, 6, 9, 12, 15]

start = 3
limit = 1
delta = -0.5
tf.range(start, limit, delta)  # [3, 2.5, 2, 1.5]

limit = 5
tf.range(limit)  # [0, 1, 2, 3, 4]
``````

`start` A 0-D `Tensor` (scalar). Acts as first entry in the range if `limit` is not None; otherwise, acts as range limit and first entry defaults to 0.
`limit` A 0-D `Tensor` (scalar). Upper limit of sequence, exclusive. If None, defaults to the value of `start` while the first entry of the range defaults to 0.
`delta` A 0-D `Tensor` (scalar). Number that increments `start`. Defaults to 1.
`dtype` The type of the elements of the resulting tensor.
`name` A name for the operation. Defaults to "range".

An 1-D `Tensor` of type `dtype`.

#### Numpy Compatibility

Equivalent to np.arange

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]