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.

Cannot train model with custom HeteroData dataset.

See original GitHub issue

šŸ› Describe the bug

Hi, first of all, thanks for the amazing work you do with PyG!

Iā€™m new to graphs and Iā€™m trying to create a custom HeteroData dataset. So far, so good; the creation of the dataset seems to work as expected. I have taken OGB_MAG dataset as reference, since the examples I saw use that one.

So, at the moment I am able to access my dataset object:

>>> dataset[0]
HeteroData(
  foo={
    x=[18, 100],
    y=[18, 1],
    train_mask=[18],
    test_mask=[18]
  },
  bar={ x=[6, 100] },
  (foo, belongs_to, bar)={ edge_index=[18, 2] },
  (bar, connects_to, bar)={ edge_index=[4, 2] }
)

I know itā€™s a small dataset object, but just for the sake of reducing processing time, I decided to get a small subset of the original dataset. So, basically there are nodes of type foo which belong/are connected to nodes of type bar, so nodes of type foo are like ā€œend nodesā€ whose edges are always connected to a node of type bar. On the other hand, nodes of type bar are entities that can be connected between themselves.

The issue Iā€™m facing is when trying to train the model with this particular graph. Iā€™m training the model using the example provided here; more precisely the class GNN.

However, the error Iā€™m experiencing is the following:

Traceback (most recent call last):
  File "main.py", line 66, in <module>
    out = model(data.x_dict, data.edge_index_dict)
  File "/usr/local/lib/python3.8/site-packages/torch/fx/graph_module.py", line 616, in wrapped_call
    raise e.with_traceback(None)
AssertionError

I know it looks very ā€œgeneralā€ and doesnā€™t have that much info, but I hope anyone has experienced something similar and is willing to give me a hand.

Thanks in advance!

Environment

  • PyG version: 2.0.3
  • PyTorch version: 1.10.2
  • OS: macOS Monterey Version 12.2.1
  • Python version: 3.8.12
  • CUDA/cuDNN version: N/A
  • How you installed PyTorch and PyG (conda, pip, source): pip
  • Any other relevant information (e.g., version of torch-scatter): N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
albertoperdomo2commented, Mar 8, 2022

Never mind, I already found the issue for this particular error. Tensorā€™s size was not correct.

0reactions
talhaubaidcommented, May 20, 2022

Alright Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

torch_geometric.data ā€” pytorch_geometric documentation
Converts a Data object to a heterogeneous HeteroData object. For this, node and edge attributes are splitted according to the node-level and edge-level...
Read more >
Loading and Training a Neural Network with Custom dataset ...
The following code snippet creates a classifier for our custom dataset, and is then added to the loaded vgg-16 model. #import OrderedDicted to...
Read more >
How to load in graph from networkx into PyTorch geometric ...
The easiest way is to add all information to the networkx graph and directly create it in the way you need it. I...
Read more >
How to define train_mask, val_mask, test_mask, ... in my own ...
I've tried to build a GCN to train my own data which are nodes with only one feature on each node. However I...
Read more >
Graph: Train, valid, and test dataset split for link prediction
Supervision edges are used as supervision for edge predictions made by the model, will not be fed into GNN! Step 2: Split edges...
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