View source on GitHub
|
Returns a RaggedTensor containing the specified sequences of numbers.
tf.ragged.range(
starts,
limits=None,
deltas=1,
dtype=None,
name=None,
row_splits_dtype=tf.dtypes.int64
)
| Used in the guide |
|---|
Each row of the returned RaggedTensor contains a single sequence:
ragged.range(starts, limits, deltas)[i] ==
tf.range(starts[i], limits[i], deltas[i])
If start[i] < limits[i] and deltas[i] > 0, then output[i] will be an
empty list. Similarly, if start[i] > limits[i] and deltas[i] < 0, then
output[i] will be an empty list. This behavior is consistent with the
Python range function, but differs from the tf.range op, which returns
an error for these cases.
tf.ragged.range([3, 5, 2]).to_list()[[0, 1, 2], [0, 1, 2, 3, 4], [0, 1]]tf.ragged.range([0, 5, 8], [3, 3, 12]).to_list()[[0, 1, 2], [], [8, 9, 10, 11]]tf.ragged.range([0, 5, 8], [3, 3, 12], 2).to_list()[[0, 2], [], [8, 10]]
The input tensors starts, limits, and deltas may be scalars or vectors.
The vector inputs must all have the same size. Scalar inputs are broadcast
to match the size of the vector inputs.
starts
Tensor. Specifies the first entry for each range
if limits is not None; otherwise, specifies the range limits, and the
first entries default to 0.
limits
Tensor. Specifies the exclusive upper limits for
each range.
deltas
Tensor. Specifies the increment for each range.
Defaults to 1.
dtype
name
row_splits_dtype
dtype for the returned RaggedTensor's row_splits
tensor. One of tf.int32 or tf.int64.
RaggedTensor of type dtype with ragged_rank=1.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.