MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / value_rowids

Method value_rowids

tensorflow/python/ops/ragged/ragged_tensor.py:957–985  ·  view source on GitHub ↗

Returns the row indices for the `values` in this ragged tensor. `rt.value_rowids()` corresponds one-to-one with the outermost dimension of `rt.values`, and specifies the row containing each value. In particular, the row `rt[row]` consists of the values `rt.values[j]` where `rt.valu

(self, name=None)

Source from the content-addressed store, hash-verified

955 return tuple(rt_nested_splits)
956
957 def value_rowids(self, name=None):
958 """Returns the row indices for the `values` in this ragged tensor.
959
960 `rt.value_rowids()` corresponds one-to-one with the outermost dimension of
961 `rt.values`, and specifies the row containing each value. In particular,
962 the row `rt[row]` consists of the values `rt.values[j]` where
963 `rt.value_rowids()[j] == row`.
964
965 Args:
966 name: A name prefix for the returned tensor (optional).
967
968 Returns:
969 A 1-D integer `Tensor` with shape `self.values.shape[:1]`.
970 The returned tensor is nonnegative, and is sorted in ascending order.
971
972 #### Example:
973 ```python
974 >>> rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []])
975 >>> rt.values
976 tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6])
977 >>> rt.value_rowids()
978 tf.Tensor([0, 0, 0, 0, 2, 2, 2, 3]) # corresponds 1:1 with rt.values
979 ```
980 """
981 if self._cached_value_rowids is not None:
982 return self._cached_value_rowids
983
984 with ops.name_scope(name, "RaggedValueRowIds", [self]):
985 return segment_id_ops.row_splits_to_segment_ids(self.row_splits)
986
987 def nested_value_rowids(self, name=None):
988 """Returns a tuple containing the value_rowids for all ragged dimensions.

Calls 1

name_scopeMethod · 0.45