View source on GitHub |
Return evenly spaced values within a given interval.
tf.keras.ops.arange(
start, stop=None, step=1, dtype=None
)
arange
can be called with a varying number of positional arguments:
arange(stop)
: Values are generated within the half-open interval[0, stop)
(in other words, the interval including start but excluding stop).arange(start, stop)
: Values are generated within the half-open interval[start, stop)
.arange(start, stop, step)
: Values are generated within the half-open interval[start, stop)
, with spacing between values given by step.
Returns | |
---|---|
Tensor of evenly spaced values.
For floating point arguments, the length of the result is
ceil((stop - start)/step) . Because of floating point overflow, this
rule may result in the last element of out being greater than stop.
|
Examples:
keras.ops.arange(3)
array([0, 1, 2], dtype=int32)
keras.ops.arange(3.0)
array([0., 1., 2.], dtype=float32)
keras.ops.arange(3, 7)
array([3, 4, 5, 6], dtype=int32)
keras.ops.arange(3, 7, 2)
array([3, 5], dtype=int32)