For example, input a 1-d tensor:
l_in = [1,1,2,2,3,4,5,5,1,3,5]
I want to remove the consecutive duplicates, which means the output should be:
l_out = [1,2,3,4,5,1,3,5]
However, the tf.unique
function only returns unique elements, indicating that the last three elements will also be eliminated. The output of tf.unique
is:
[1,2,3,4,5], [0,0,1,1,2,3,4,4,0,2,4] = tf.unique(l_in)
where the second item is the corresponding IDs.
Is there any way to only remove consecutive duplicates while preserving non-duplicated and non-unique elements?