Trova elementi unici lungo un asse di un tensore.
Questa operazione restituisce un tensore "y" contenente elementi univoci lungo l'"asse" di un tensore. Gli elementi univoci restituiti vengono ordinati nello stesso ordine in cui si trovano lungo "axis" in "x". Questa operazione restituisce anche un tensore "idx" e un tensore "count" che hanno la stessa dimensione del numero di elementi in "x" lungo la dimensione "axis". "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 `axis = None:
`y[idx[i]] = x[i] per i in [0, 1,...,rank(x) - 1]`
Per 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 `asse = 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 `asse = 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> | contare () Un tensore 1-D. |
statico <T, V estende Numero, U estende Numero> UniqueWithCounts <T, V> | |
statico <T, U estende Numero> UniqueWithCounts <T, Integer> | |
Uscita <V> | idx () Un tensore 1-D. |
Uscita <T> | sì () 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
ambito | ambito attuale |
---|---|
X | Un "Tensore". |
asse | Un "Tensore" di tipo "int32" (impostazione predefinita: Nessuno). L'asse del Tensore per trovare gli elementi unici. |
Ritorni
- 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
ambito | ambito attuale |
---|---|
X | Un "Tensore". |
asse | Un "Tensore" di tipo "int32" (impostazione predefinita: Nessuno). L'asse del Tensore per trovare gli elementi unici. |
Ritorni
- una nuova istanza di UniqueWithCounts
Uscita pubblica <V> idx ()
Un tensore 1-D. Ha lo stesso tipo di x che contiene l'indice di ogni valore di x nell'output y.