question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Raise error "IndexError: index out of range in self" using NeighborLoader

See original GitHub issue

šŸ› Describe the bug

I used the neighbor_loader to sample my graph data. Although i used proper data, raise this error.

Usage is this:

NeighborLoader(
            processed_pyg_data,
            batch_size=self.args.batch_size,
            num_neighbors=[
                16,
                32,
            ]
        )

I think that my dataset is clean and unproblematic. Because i used this dataset in other projects with neighbor_loader at M1 Sillicon environment. But, in the ubuntu, raise this error below. Whatā€™s wrongā€¦ Plz help meā€¦

  File "/home/ubuntu/anaconda3/envs/kisa-test/lib/python3.8/site-packages/torch_geometric/loader/base.py", line 36, in __next__
    return self.transform_fn(next(self.iterator))
  File "/home/ubuntu/anaconda3/envs/kisa-test/lib/python3.8/site-packages/torch_geometric/loader/neighbor_loader.py", line 405, in filter_fn
    data = filter_data(self.data, node, row, col, edge,
  File "/home/ubuntu/anaconda3/envs/kisa-test/lib/python3.8/site-packages/torch_geometric/loader/utils.py", line 158, in filter_data
    filter_node_store_(data._store, out._store, node)
  File "/home/ubuntu/anaconda3/envs/kisa-test/lib/python3.8/site-packages/torch_geometric/loader/utils.py", line 111, in filter_node_store_
    out_store[key] = index_select(value, index, dim=dim)
  File "/home/ubuntu/anaconda3/envs/kisa-test/lib/python3.8/site-packages/torch_geometric/loader/utils.py", line 26, in index_select
    return torch.index_select(value, dim, index, out=out)
IndexError: index out of range in self

Environment

  • PyG version: 2.0.4
  • PyTorch version: 1.12.0
  • OS: Ubuntu
  • Python version: 3.8
  • CUDA/cuDNN version: None (CPU)
  • How you installed PyTorch and PyG (conda, pip, source): pip
  • Any other relevant information (e.g., version of torch-scatter):

torch-cluster 1.6.0 torch-geometric 2.1.0.post1 torch-scatter 2.0.9 torch-sparse 0.6.15 torch-spline-conv 1.2.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Padarncommented, Nov 5, 2022

Iā€™m wondering if we should add some better error messages around these kinds of common problems (Iā€™ve seen a question similar to this quite a few times).

0reactions
davidlambda256commented, Nov 8, 2022

Ok. Iā€™ll give an example. The ā€œdamageā€ happens in this case below:

[STEP1] Preprocessing and Save (environment: Mac M1 sillicon)

        node_numerical_features = self._get_numerical_features(kind=kind)
        edge_structure, weight = self._get_graph_structure_features(kind=kind)
        labels = self._get_encoded_labels(kind=kind)

        processed_dataset = Data(
            x=node_numerical_features,
            edge_index=edge_structure,
            edge_attr=weight,
            y=labels,
        )

        torch.save(processed_dataset, "pyg_data.pt")

Then, i save the processed data using pyg, and load it in step2

[STEP2] Load the saved data (environment: Ubuntu 18.04)

       torch.load("pyg_data.pt")

The damage happens in STEP2. When i identified the loaded data, edge_index is damaged (e.g. Some elements in the loaded data changed negative values) Currently, i cannot find causes of this error. If i identify this issue, iā€™ll share you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pytorch: IndexError: index out of range in self. How to solve?
Any input less than zero or more than declared input dimension raise this error. Compare your input and the dimension mentioned in torch.nn....
Read more >
IndexError: index out of range in self Ā· Issue #5611 - GitHub
IndexError : index out of range in self. I tried to set max_words length as 400, still getting same error : Data I...
Read more >
Transformer Embedding - IndexError: index out of range in self
I'm training a transformer model from scratch, and was able to run a ā€œminiā€ train and dev set on the CPU without any...
Read more >
[LayoutLMv3] index out of range in self inside outputs = model ...
Thanks @nielsr for the implementation! I'm trying to fine-tune the model based on my own dataset following this: Google Colab.
Read more >
IndexError: list index out of range for `get_pred` - Fast.ai forums
When I tried to call predict on them. pred_fwd,lbl_fwd = learn_fwd.get_preds(ordered=True). I recieve the following error:Ā ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found