tf.edit_distance

Computes the Levenshtein distance between sequences.

This operation takes variable-length sequences (hypothesis and truth), each provided as a SparseTensor, and computes the Levenshtein distance. You can normalize the edit distance by length of truth by setting normalize to true.

For example:

Given the following input,

hypothesis = tf.SparseTensor(
  [[0, 0, 0],
   [1, 0, 0]],
  ["a", "b"],
  (2, 1, 1))
truth = tf.SparseTensor(
  [[0, 1, 0],
   [1, 0, 0],
   [1, 0, 1],