Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got the following error during the testing #8

Open
yihanjjj opened this issue Jun 10, 2022 · 2 comments
Open

Got the following error during the testing #8

yihanjjj opened this issue Jun 10, 2022 · 2 comments

Comments

@yihanjjj
Copy link

yihanjjj commented Jun 10, 2022

Traceback (most recent call last):
File "new_main.py", line 120, in
for user, batch_graph, label, last_item, neg_tar in test_data:
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/torch/_utils.py", line 434, in reraise
raise exception
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
return self.collate_fn(data)
File "new_main.py", line 92, in
test_data = DataLoader(dataset=test_set, batch_size=opt.batchSize, collate_fn=lambda x: collate_test(x, data_neg), pin_memory=True, num_workers=8)
File "/export/hdd/scratch/yjiang400/DGSR/DGSR.py", line 341, in collate_test
return torch.tensor(user).long(), dgl.batch(graph), torch.tensor(label).long(), torch.tensor(last_item).long(), torch.Tensor(neg_generate(user, user_neg)).long()
File "/export/hdd/scratch/yjiang400/DGSR/DGSR.py", line 326, in neg_generate
neg[i] = np.random.choice(data_neg[u], neg_num, replace=False)
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/pandas/core/series.py", line 871, in getitem
result = self.index.get_value(self, key)
File "/usr/scratch/yjiang400/miniconda3/envs/dgsr/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 4405, in get_value
return self._engine.get_value(s, k, tz=getattr(series.dtype, "tz", None))
File "pandas/_libs/index.pyx", line 80, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 90, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 135, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index_class_helper.pxi", line 109, in pandas._libs.index.Int64Engine._check_type
KeyError: tensor([0])

@yihanjjj yihanjjj changed the title How to disable the training and only enable the inference? Got the following error during the testing Jun 10, 2022
@ZM7
Copy link
Collaborator

ZM7 commented Jul 18, 2022

You may try to change np.random.choice(data_neg[u], neg_num, replace=False) to np.random.choice(data_neg[u.item()], neg_num, replace=False) in line 326 of DGSR.py.

@wbcat132
Copy link

Have you settle the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants