Trova elementi unici lungo un asse di un tensore.
Questa operazione restituisce un tensore "y" contenente elementi unici lungo l '"asse" di un tensore. Gli elementi univoci restituiti sono ordinati nello stesso ordine in cui si trovano lungo "axis" in "x". Questa operazione restituisce anche un tensore "idx" e un tensore "count" della stessa dimensione del numero degli elementi in "x" lungo la dimensione di "asse". "Idx" contiene l'indice nell'output univoco "y" e "count" contiene il conteggio nell'output univoco "y". In altre parole, per un tensore "1-D" "x" con "asse = Nessuno":
"y [idx [i]] = x [i] for i in [0, 1, ..., rank (x) - 1]"
Ad esempio:
# 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]
Per un tensore `2-D`` x` con `axis = 0`: # tensor 'x' is [[1, 0, 0],
# [1, 0, 0],
# [2, 0, 0]]
y, idx, count = unique_with_counts(x, axis=0)
y ==> [[1, 0, 0],
[2, 0, 0]]
idx ==> [0, 0, 1]
count ==> [2, 1]
Per un tensore` 2-D` `x` con` axis = 1`: # tensor 'x' is [[1, 0, 0],
# [1, 0, 0],
# [2, 0, 0]]
y, idx, count = unique_with_counts(x, axis=1)
y ==> [[1, 0],
[1, 0],
[2, 0]]
idx ==> [0, 1, 1]
count ==> [1, 2]
Metodi pubblici
Uscita <V> | conteggio () Un tensore 1-D. |
static <T, V estende il numero, U estende il numero> UniqueWithCounts <T, V> | |
static <T, U extends Number> UniqueWithCounts <T, Integer> | |
Uscita <V> | idx () Un tensore 1-D. |
Uscita <T> | y () Un "tensore". |
Metodi ereditati
Metodi pubblici
public static UniqueWithCounts <T, V> create ( ambito ambito, operando <T> x, operando <U> asse, classe <V> outIdx)
Metodo Factory per creare una classe che racchiude una nuova operazione UniqueWithCounts.
Parametri
scopo | ambito attuale |
---|---|
X | Un "tensore". |
asse | Un "Tensore" di tipo "int32" (predefinito: Nessuno). L'asse del tensore per trovare gli elementi unici. |
ritorna
- una nuova istanza di UniqueWithCounts
public static UniqueWithCounts <T, Integer> create ( ambito ambito, operando <T> x, operando <U> asse)
Metodo Factory per creare una classe che racchiude una nuova operazione UniqueWithCounts utilizzando i tipi di output predefiniti.
Parametri
scopo | ambito attuale |
---|---|
X | Un "tensore". |
asse | Un "Tensore" di tipo "int32" (predefinito: Nessuno). L'asse del tensore per trovare gli elementi unici. |
ritorna
- una nuova istanza di UniqueWithCounts
output pubblico <V> idx ()
Un tensore 1-D. Ha lo stesso tipo di x che contiene l'indice di ciascun valore di x nell'output y.