Skip to content

Commit

Permalink
Fix recall at k when batch size = 1 (#779)
Browse files Browse the repository at this point in the history
Co-authored-by: sungho-ham <[email protected]>
  • Loading branch information
sungho-ham and sungho-ham committed Aug 6, 2024
1 parent 23d5e3b commit 73782c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion transformers4rec/torch/ranking_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _metric(self, ks: torch.Tensor, scores: torch.Tensor, labels: torch.Tensor)

# Compute recalls at K
num_relevant = torch.sum(labels, dim=-1)
rel_indices = (num_relevant != 0).nonzero().squeeze()
rel_indices = (num_relevant != 0).nonzero().squeeze(dim=1)
rel_count = num_relevant[rel_indices]

if rel_indices.shape[0] > 0:
Expand Down

0 comments on commit 73782c9

Please sign in to comment.