1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
op {
graph_op_name: "EditDistance"
in_arg {
name: "hypothesis_indices"
description: <<END
The indices of the hypothesis list SparseTensor.
This is an N x R int64 matrix.
END
}
in_arg {
name: "hypothesis_values"
description: <<END
The values of the hypothesis list SparseTensor.
This is an N-length vector.
END
}
in_arg {
name: "hypothesis_shape"
description: <<END
The shape of the hypothesis list SparseTensor.
This is an R-length vector.
END
}
in_arg {
name: "truth_indices"
description: <<END
The indices of the truth list SparseTensor.
This is an M x R int64 matrix.
END
}
in_arg {
name: "truth_values"
description: <<END
The values of the truth list SparseTensor.
This is an M-length vector.
END
}
in_arg {
name: "truth_shape"
description: <<END
truth indices, vector.
END
}
out_arg {
name: "output"
description: <<END
A dense float tensor with rank R - 1.
For the example input:
// hypothesis represents a 2x1 matrix with variable-length values:
// (0,0) = ["a"]
// (1,0) = ["b"]
hypothesis_indices = [[0, 0, 0],
[1, 0, 0]]
hypothesis_values = ["a", "b"]
hypothesis_shape = [2, 1, 1]
// truth represents a 2x2 matrix with variable-length values:
// (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
The output will be:
// output is a 2x2 matrix with edit distances normalized by truth lengths.
output = [[inf, 1.0], // (0,0): no truth, (0,1): no hypothesis
[0.5, 1.0]] // (1,0): addition, (1,1): no hypothesis
END
}
attr {
name: "normalize"
description: <<END
boolean (if true, edit distances are normalized by length of truth).
The output is:
END
}
summary: "Computes the (possibly normalized) Levenshtein Edit Distance."
description: <<END
The inputs are variable-length sequences provided by SparseTensors
(hypothesis_indices, hypothesis_values, hypothesis_shape)
and
(truth_indices, truth_values, truth_shape).
The inputs are:
END
}
|