Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiwen Yuan committed Oct 24, 2024
1 parent a15ab8b commit 7819215
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/ijcai_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ def test(loader: NeighborLoader, desc: str, target=None) -> np.ndarray:
if target is not None:
# randomly select num_item indices
batch_user = scores.shape[0]
trnLabel[batch['user'].n_id]
# full set is the sampled rhs set
# you pick 99 items from the sampled rhs set.

Expand All @@ -368,12 +367,12 @@ def test(loader: NeighborLoader, desc: str, target=None) -> np.ndarray:
0, num_sampled_rhs, (batch_user, 100)).to(
scores.device) # Shape: (batch_user, 100)
for i in range(batch_size):
user_idx = batch[src_entity_table].n_id[i]
user_idx = batch[src_entity_table].n_id[i].cpu()
neg_item_per_user = np.reshape(
np.argwhere(trnLabel[user_idx].toarray().reshape(-1) == 0),
[-1])
neg_item_per_user_sampled = np.intersect1d(
all_sampled_rhs, neg_item_per_user)
all_sampled_rhs.cpu(), neg_item_per_user)
random_items[i, :] = torch.tensor(
np.random.choice(neg_item_per_user_sampled, size=100,
replace=False),
Expand Down

0 comments on commit 7819215

Please sign in to comment.