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

IndexError: list index out of range for torch.load(glob.glob(prot_1)[0]) #2

Open
XueWang2019 opened this issue Jun 13, 2022 · 2 comments

Comments

@XueWang2019
Copy link

XueWang2019 commented Jun 13, 2022

Dear Sir/Madam,

My update:
As I don't have the completed dataset, I guess the original issue comes from below reasons:

  1. npy_file_new(human_dataset).npy has 22217 data
  2. Current available human data is only 4444+1111=5555
    Above causes the below problem. Please feel free to correct me. Thanks.

Original issue:
I am running this project on google colab. This might not be an issue, but I don't know how to solve it.
There is a problem showing as : IndexError: list index out of range.
The part of result as:
GCNN Loaded Training on 4444 samples..... 15657 first prot is /content/gdrive/MyDrive/PPI_GNN/PPI_GNN/human_features/processed/3AIH.pt [] 15657 Second prot is /content/gdrive/MyDrive/PPI_GNN/PPI_GNN/human_features/processed/1DEV.pt Traceback (most recent call last): File "train.py", line 97, in <module> train(model, device, trainloader, optimizer, epoch+1) File "train.py", line 45, in train for count,(prot_1, prot_2, label) in enumerate(trainloader): File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 530, in __next__ data = self._next_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 570, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataset.py", line 471, in __getitem__ return self.dataset[self.indices[idx]] File "/content/gdrive/MyDrive/PPI_GNN/PPI_GNN/data_prepare.py", line 41, in __getitem__ prot_1 = torch.load(glob.glob(prot_1)[0]) IndexError: list index out of range

The error comes from the code:
def __getitem__(self, index): prot_1 = os.path.join(self.processed_dir, self.protein_1[index]+".pt") print(index) print(f'first prot is {prot_1}') print(glob.glob('prot_1')) prot_2 = os.path.join(self.processed_dir, self.protein_2[index]+".pt") print(index) print(f'Second prot is {prot_2}') prot_1 = torch.load(glob.glob(prot_1)[0]) print(f'Here lies {glob.glob(prot_2)}') prot_2 = torch.load(glob.glob(prot_2)[0]) print(torch.tensor(self.label[index])) return prot_1, prot_2, torch.tensor(self.label[index])

It seems that glob.glob('prot_1') is null. How to solve this problem?
Thanks in advance.

@yangyangdotcom
Copy link

yangyangdotcom commented Sep 24, 2022

I go the same problem and fixed it by replacing the processed folder with this https://drive.google.com/file/d/1mpMB2Gu6zH6W8fZv-vGwTj_mmeitIV2-/view?usp=sharing. Hope it solves your problem

@HajerBashir
Copy link

@yangyangdotcom the link is not working ??

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