tft.segment_indices

Returns a Tensor of indices within each segment.

segment_ids should be a sequence of non-decreasing non-negative integers that define a set of segments, e.g. [0, 0, 1, 2, 2, 2] defines 3 segments of length 2, 1 and 3. The return value is a Tensor containing the indices within each segment.

Example:

result = tft.segment_indices(tf.constant([0, 0, 1, 2, 2, 2]))
print(result)
tf.Tensor([0 1 0 0 1 2], shape=(6,), dtype=int32)

segment_ids A 1-d Tensor containing an non-decreasing sequence of non-negative integers with type tf.int32 or tf.int64.
name (Optional) A name for this operation.

A Tensor containing the indices within each segment.