Loading TOC...

cntk.editDistanceError

cntk.editDistanceError(
   $prediction as cntk.variable,
   $labels as cntk.variable,
   $substitution-penalty as Number,
   $deletion-penalty as Number,
   $insertion-penalty as Number,
   $squash-inputs as Boolean,
   $tokens-to-ignore as Number[],
   [$name as String]
) as cntk.function

Summary

Edit distance error evaluation function with the option of specifying penalty of substitution, deletion and insertion, as well as squashing the input sequences and ignoring certain samples. Using the classic DP algorithm as described in https://en.wikipedia.org/wiki/Edit_distance, adjusted to take into account the penalties.

Parameters
$prediction First input sequence.
$labels Second input sequence.
$substitution-penalty Substitution penalty.
$deletion-penalty Deletion penalty.
$insertion-penalty Insertion penalty.
$squash-inputs Whether to merge sequences of identical samples (in both input sequences). If true and tokensToIgnore contains label ‘-‘ then given first input sequence as s1=”a-ab-” and second as s2=”-aa–abb” the edit distance will be computed against s1’ = “aab” and s2’ = “aab”.
$tokens-to-ignore List of indices of samples to ignore during edit distance evaluation (in both sequences)
$name The name of the Function instance in the network.

Example

  var inputVariable1 = cntk.inputVariable(cntk.shape([3]), "float", fn.false(),
    fn.false(), "feature")
  var inputVariable2 = cntk.inputVariable(cntk.shape([3]), "float", fn.false(),
    fn.false(), "feature")
  cntk.editDistanceError(inputVariable2, inputVariable1, -2513.533315,
    -917.839638, -503.608250, fn.true(), (7304744922439162672,
    -9672540140625912601))
  => cntk.function(Composite EditDistanceError (Input(Name(feature), Shape([3]),
  Dynamic Axes([Sequence Axis(Default Dynamic Axis), Batch Axis(Default Batch
  Axis)])), Input(Name(feature), Shape([3]), Dynamic Axes([Sequence Axis(Default
  Dynamic Axis), Batch Axis(Default Batch Axis)]))))

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.