Skip to content

Commit

Permalink
Merge branch 'RUCAIBox:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengbw0324 authored Mar 30, 2024
2 parents d6567a8 + 48f13e9 commit 502e25c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions recbole/model/sequential_recommender/fearec.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,16 @@ def calculate_loss(self, interaction):
lens = len(targets_index)
if lens == 0:
print("error")
while True:
sample_index = random.choice(targets_index)
remaining_indices = targets_index.copy()
while len(remaining_indices) > 0:
sample_index = random.choice(remaining_indices)
remaining_indices = remaining_indices[remaining_indices != sample_index]
cur_item_list = interaction[self.ITEM_SEQ][i].to("cpu")
sample_item_list = dataset.inter_feat[self.ITEM_SEQ][sample_index]
are_equal = torch.equal(cur_item_list, sample_item_list)
sample_item_length = dataset.inter_feat[self.ITEM_SEQ_LEN][sample_index]
if not are_equal or lens == 1:

if not are_equal or len(remaining_indices) == 0:
sem_pos_lengths.append(sample_item_length)
sem_pos_seqs.append(sample_item_list)
break
Expand Down

0 comments on commit 502e25c

Please sign in to comment.