W3cubDocs

/TensorFlow 2.3

tf.nn.collapse_repeated

View source on GitHub

Merge repeated labels into single labels.

Args
labels Tensor of shape [batch, max value in seq_length]
seq_length Tensor of shape [batch], sequence length of each batch element.
name A name for this Op. Defaults to "collapse_repeated_labels".
Returns
A tuple (collapsed_labels, new_seq_length) where
collapsed_labels Tensor of shape [batch, max_seq_length] with repeated labels collapsed and padded to max_seq_length, eg: [[A, A, B, B, A], [A, B, C, D, E]] => [[A, B, A, 0, 0], [A, B, C, D, E]]
new_seq_length int tensor of shape [batch] with new sequence lengths.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/nn/collapse_repeated