From bee1d49a45338bbad8adad8763c810b863dc10e4 Mon Sep 17 00:00:00 2001 From: Daniel Justus Date: Thu, 2 Nov 2023 13:23:14 +0000 Subject: [PATCH] nan to -inf --- besskge/metric.py | 1 + 1 file changed, 1 insertion(+) diff --git a/besskge/metric.py b/besskge/metric.py index 394c0a2..aa1bdcb 100644 --- a/besskge/metric.py +++ b/besskge/metric.py @@ -149,6 +149,7 @@ def ranks_from_scores( raise ValueError( "`pos_score` and `candidate_score` need to have same size at dimension 0" ) + pos_score.nan_to_num_(-torch.inf) if self.mode == "optimistic": n_better = torch.sum(candidate_score > pos_score, dim=-1).to(torch.float32)