This commit is contained in:
weixin_43297441 2025-03-24 11:01:49 +08:00
parent 5b6b54f6c0
commit ba518178a1
1 changed files with 5 additions and 1 deletions

View File

@ -955,3 +955,7 @@ You are an AI assistant. You'll provide helpful, harmless, and detailed response
# "\n#Right Answer#: " + answer +
"\n#Answer#: "}
]
def mahalanobis_distance(x, mean, cov):
cov_inv = torch.inverse(cov)
delta = x - mean
return torch.sqrt(torch.einsum('bi,ij,bj->b', delta, cov_inv, delta))