Calcola la distanza di modifica Levenshtein (possibilmente normalizzata).
Gli input sono sequenze di lunghezza variabile fornite da SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) e (truth_indices, truth_values, truth_shape).
Gli ingressi sono:
Classi annidate
classe | EditDistance.Options | Attributi opzionali per EditDistance |
Metodi pubblici
Uscita <Float> | asOutput () Restituisce la maniglia simbolica di un tensore. |
static <T> EditDistance | create ( Scope scope, Operand <Long> hypothesisIndices, Operand <T> hypothesisValues, Operand <Long> hypothesisShape, Operand <Long> truthIndices, Operand <T> truthValues, Operand <Long> truthShape, Opzioni ... opzioni) Metodo Factory per creare una classe che avvolge una nuova operazione EditDistance. |
static EditDistance.Options | normalize (Boolean normalize) |
Uscita <Float> | output () Un tensore flottante denso con rango R - 1. |
Metodi ereditati
Metodi pubblici
output pubblico <Float> asOutput ()
Restituisce la maniglia simbolica di un tensore.
Gli input per le operazioni TensorFlow sono output di un'altra operazione TensorFlow. Questo metodo viene utilizzato per ottenere un handle simbolico che rappresenta il calcolo dell'input.
public static EditDistance create ( Scope scope, Operand <Long> hypothesisIndices, Operand <T> hypothesisValues, Operand <Long> hypothesisShape, Operand <Long> truthIndices, Operand <T> truthValues, Operand <Long> truthShape, Opzioni ...
Metodo Factory per creare una classe che avvolge una nuova operazione EditDistance.
Parametri
scopo | ambito attuale |
---|---|
ipotesiIndici | Gli indici dell'ipotesi elencano SparseTensor. Questa è una matrice N x R int64. |
hypothesisValues | I valori dell'elenco delle ipotesi SparseTensor. Questo è un vettore di lunghezza N. |
hypothesisShape | La forma dell'elenco delle ipotesi SparseTensor. Questo è un vettore di lunghezza R. |
veritàIndici | Gli indici della lista di verità SparseTensor. Questa è una matrice M x R int64. |
veritàValori | I valori della lista di verità SparseTensor. Questo è un vettore di lunghezza M. |
truthShape | indici di verità, vettore. |
opzioni | trasporta valori di attributi opzionali |
ritorna
- una nuova istanza di EditDistance
public static EditDistance.Options normalize (Boolean normalize)
Parametri
normalizzare | booleano (se true, le distanze di modifica sono normalizzate in base alla lunghezza della verità). L'output è: |
---|
output pubblico <Float> output ()
Un tensore flottante denso con rango R - 1.
Per l'input di esempio:
// hypothesis rappresenta una matrice 2x1 con valori di lunghezza variabile: // (0,0) = ["a"] // (1,0) = ["b"] hypothesis_indices = [[0, 0, 0], [1, 0, 0]] valori_ipotesi = ["a", "b"] forma_ipotesi = [2, 1, 1]
// la verità rappresenta una matrice 2x2 con valori di lunghezza variabile: // (0,0) = [] // (0,1) = ["a"] // (1,0) = ["b", " c "] // (1,1) = [" a "] truth_indices = [[0, 1, 0], [1, 0, 0], [1, 0, 1], [1, 1, 0] ] truth_values = ["a", "b", "c", "a"] truth_shape = [2, 2, 2] normalize = true
L'output sarà:
// l'output è una matrice 2x2 con distanze di modifica normalizzate dalle lunghezze di verità. output = [[inf, 1.0], // (0,0): nessuna verità, (0,1): nessuna ipotesi [0.5, 1.0]] // (1,0): addizione, (1,1): nessuna ipotesi