Creates a sequence of numbers.
Aliases:
tf.compat.v1.range
tf.compat.v2.range
tf.range(limit, delta=1, dtype=None, name='range')
tf.range(start, limit, delta=1, dtype=None, name='range')
Used in the guide:
B
et
te
rp
e
rf
or
ma
nc
ew
i
th
t
f.
fu
nc
ti
on
a
nd
A
ut
oG
ra
ph
T
ra
in
in
gc
h
ec
kp
oi
nt
s``
Used in the tutorials:
B
et
te
rp
e
rf
or
ma
nc
ew
i
th
t
f.
fu
nc
ti
on
D
ee
pD
re
am
T
ra
ns
fo
rm
er
m
od
el
f
or
l
an
gu
ag
eu
n
de
rs
ta
nd
in
g`` Creates a sequence of numbers that begins atstart
and extends by increments ofdelta
up to but not includinglimit
. The dtype of the resulting tensor is inferred from the inputs unless it is provided explicitly. Like the Python builtinrange
,start
defaults to 0, so thatrange
(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]
Args:
start
: A 0-DTensor
(scalar). Acts as first entry in the range iflimit
is not None; otherwise, acts as rangelimit
and first entry defaults to 0.limit
: A 0-DTensor
(scalar). Upperlimit
of sequence, exclusive. If None, defaults to the value ofstart
while the first entry of the range defaults to 0.delta
: A 0-DTensor
(scalar). Number that incrementsstart
. Defaults to 1.dtype
: The type of the elements of the resulting tensor.name
: Aname
for the operation. Defaults to "range".
Returns:
An 1-D Tensor
of type dtype
.
Numpy Compatibility
Equivalent to np.arange