metric

levenshtein_distance

Overview:

Levenshtein Distance, i.e. Edit Distance.

Arguments:
  • pred (torch.LongTensor): shape: (N1, ) (N1 >= 0)

  • target (torch.LongTensor): shape: (N2, ) (N2 >= 0)

  • pred_extra (Optional[torch.Tensor])

  • target_extra (Optional[torch.Tensor])

  • extra_fn (Optional[Callable]): if specified, the distance metric of the extra input data

Returns:
  • distance (torch.FloatTensor): distance(scalar), shape: (1, )

hamming_distance

Overview:

Hamming Distance

Arguments:
  • pred (torch.LongTensor): pred input, boolean vector(0 or 1)

  • target (torch.LongTensor): target input, boolean vector(0 or 1)

  • weight (torch.LongTensor): weight to multiply

Returns:
  • distance(torch.LongTensor): distance(scalar), shape (1, )

Shapes:
  • pred & target (torch.LongTensor): shape \((B, N)\),

    while B is the batch size, N is the dimension