T - data type for y() outputU - data type for idx() output@Operator public final class UniqueWithCounts<T,U extends Number> extends PrimitiveOp
This operation returns a tensor `y` containing all of the unique elements of `x` sorted in the same order that they occur in `x`. This operation also returns a tensor `idx` the same size as `x` that contains the index of each value of `x` in the unique output `y`. Finally, it returns a third tensor `count` that contains the count of each element of `y` in `x`. In other words:
`y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]`
For example:
# tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx, count = unique_with_counts(x)
y ==> [1, 2, 4, 7, 8]
idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]
count ==> [2, 1, 3, 1, 2]
operation| Modifier and Type | Method and Description |
|---|---|
Output<U> |
count()
1-D.
|
static <T> UniqueWithCounts<T,Integer> |
create(Scope scope,
Operand<T> x)
Factory method to create a class to wrap a new UniqueWithCounts operation to the graph, using default output types.
|
static <T,U extends Number> |
create(Scope scope,
Operand<T> x,
Class<U> outIdx)
Factory method to create a class to wrap a new UniqueWithCounts operation to the graph.
|
Output<U> |
idx()
1-D.
|
Output<T> |
y()
1-D.
|
equals, hashCode, toStringpublic static <T,U extends Number> UniqueWithCounts<T,U> create(Scope scope, Operand<T> x, Class<U> outIdx)
scope - current graph scopex - 1-D.outIdx - public static <T> UniqueWithCounts<T,Integer> create(Scope scope, Operand<T> x)
scope - current graph scopex - 1-D.Copyright © 2015–2019. All rights reserved.