We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d2e3d98 commit acde4fdCopy full SHA for acde4fd
aiu_fms_testing_utils/utils/metrics_utils.py
@@ -45,7 +45,6 @@ def tensor_abs_diff(tensor1, tensor2):
45
torch.tensor([3, 3, 3])
46
"""
47
abs_diff = torch.abs(tensor1 - tensor2)
48
- abs_diff[abs_diff == 0.0] = 1e-6
49
return abs_diff
50
51
def tensor_cos_sim(tensor1, tensor2):
@@ -67,6 +66,7 @@ def tensor_cos_sim(tensor1, tensor2):
67
66
>>> print(sim)
68
69
cos = nn.CosineSimilarity(dim=-1)
+ tensor1[tensor1 == 0.0] = 1e-6
70
+ tensor2[tensor2 == 0.0] = 1e-6
71
cos_sim = cos(tensor1, tensor2)
- cos_sim[cos_sim == 0.0] = 1e-6
72
return cos_sim
0 commit comments