Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion recbole/model/general_recommender/pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def forward(self):

def calculate_loss(self, interaction):
item = interaction[self.ITEM_ID]
self.item_cnt[item, :] = self.item_cnt[item, :] + 1
# Use scatter_add_ for proper accumulation of duplicate items in batch
ones = torch.ones_like(item).unsqueeze(1).to(dtype=self.item_cnt.dtype)
self.item_cnt.scatter_add_(0, item.unsqueeze(1), ones)

self.max_cnt = torch.max(self.item_cnt, dim=0)[0]

Expand Down