Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Make distance metrics return tensors, fix #700 #701 #702

Merged
merged 1 commit into from Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/vak/metrics/distance/functional.py
@@ -1,4 +1,5 @@
import numpy as np
import torch


def levenshtein(source, target):
Expand Down Expand Up @@ -65,7 +66,7 @@ def levenshtein(source, target):

d0, d1 = d1, d0

return d0[-1]
return torch.tensor(d0[-1], dtype=torch.int32)


def segment_error_rate(y_pred, y_true):
Expand Down Expand Up @@ -95,4 +96,5 @@ def segment_error_rate(y_pred, y_true):
"segment error rate is undefined when length of y_true is zero"
)

return levenshtein(y_pred, y_true) / len(y_true)
rate = levenshtein(y_pred, y_true) / len(y_true)
return torch.tensor(rate, dtype=torch.float32)