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.

Data Batch problem in PyG

See original GitHub issue

🐛 Describe the bug

Hi. I am a computational physics researcher and was using PyG very well. my pyg code was working well a few weeks ago, but now that I run my code, it is not working anymore without any changes.

the problem is like below. I have many material structures and in my “custom_dataset” class, these are preprocessed and all graph informations (node features, edge features, edge index etc) are inserted into “Data” object in PyTorch geometric. You can see that each preprocessed sample with index $i$ was printed normal “Data” object in pyg

캡처2

But When I insert my custom dataset class into pyg DataLoader and I did like below,

sample = next(iter(train_loader)) # batch sample

batch sample is denoted by “DataDataBatch”. I didn’t see this kind of object name. and i can’t use "sample.x’ or “sample.edge_index” command. Instead I need to do like this

캡처3

I want to use expressions like “sample.x”, “sample.edge_index” or “sample.edge_attr” as like before. I expect your kind explanations. Thank you.

Environment

  • PyG version: 2.0.5
  • PyTorch version: 1.11.0+cu113
  • OS: GoogleColab Pro Plus
  • Python version: Python 3.7.13 in colab
  • CUDA/cuDNN version:
  • How you installed PyTorch and PyG (conda, pip, source):
# Install required packages.
import os
import torch
os.environ['TORCH'] = torch.__version__
print(torch.__version__)
!pip install -q torch-scatter -f https://data.pyg.org/whl/torch-${TORCH}.html
!pip install -q torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}.html
!pip install -q git+https://github.com/pyg-team/pytorch_geometric.git
!pip install -q pymatgen==2020.11.11  
  • Any other relevant information (e.g., version of torch-scatter):

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:29 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
de-gozarucommented, Aug 22, 2022

Hi @rusty1s Thanks for your response! Indeed, I’m a little bit busy these days, and I’m already using the filtering solution. I hope I’ll find some time to debug it soon.

0reactions
rusty1scommented, Aug 20, 2022

Oh, what a bummer. I was pretty sure we fixed the root cause of this issue 😦 Is it possible for you to upload some dummy data of yours which we could use to try to reproduce? It would be also great if you could try to debug the execution of https://github.com/pyg-team/pytorch_geometric/blob/master/torch_geometric/data/separate.py#L59, e.g., what’s the output of print(key, value.shape, idx, cat_dim, start, end) right before the crash?

If you wanna stay on 2.0.4, you can filter out the warning via warnings.filterwarnings("ignore", ".*one or more elements.*")

Read more comments on GitHub >

github_iconTop Results From Across the Web

torch_geometric.data.batch - PyTorch Geometric
data. batch. [docs]class Batch(metaclass=DynamicInheritance): r"""A data object describing a batch of graphs as one big (disconnected) graph.
Read more >
Advanced mini-batching [Advanced PyTorch Geometric ...
Pytorch Geometric tutorial: Data handling in PyTorch Geometric ... Open Graph Benchmark and PyG [Advanced PyTorch Geometric Tutorial 1].
Read more >
Overfitting issue in GNN on Colab - PyTorch Forums
Hello everyone, I have been trying to train a GNN using PyG for a ... on significantly similar problems), and changing the batchsize....
Read more >
Hands-on Graph Neural Networks with PyTorch & PyTorch ...
(PyG), a Graph Neural Network framework built on top of PyTorch ... The DataLoader class allows you to feed data by batch into...
Read more >
Breakdown of an ogbn-products epoch batch preparation time ...
Breakdown of an ogbn-products epoch batch preparation time for PyG and SALIENT with P threads on 20 cores. Note that for PyG Both...
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