I’m learning to use PyTorch Geometric, I tried to replicate the WL kernel written by the PyG developers on GitHub (https://github.com/pyg-team/pytorch_geometric/blob/master/examples/wl_kernel.py), but when I run the program I get this error which I can’t solve:

enter image description here

I use a custom dataset where the data looks like:

Data(x=[9, 9], edge_index=[2, 18], edge_attr=[18, 2], y=[0])

Exactly like in the example. Which one had the same problem and was able to solve it? Thank you all!

  • 2
    $\begingroup$ Since the error is specific to PyTorch and at least this particular question doesn't require the chemical/material background you describe in your other questions, this may be better suited for Artificial Intelligence or StackOverflow. If you would rather keep it here, it would be best if you post the full error message as a code block rather than an image. $\endgroup$
    – Tyberius
    Mar 3, 2022 at 15:08
  • 2
    $\begingroup$ I agree with @Tyberius that this is not a chemistry/materials modeling question, however, I do not think it is a SE question at all. You have an assertion error related to the dimensions of x - it is not a general problem of PyTorch. Your best bet is directly contact the authors $\endgroup$
    – Greg
    Mar 3, 2022 at 16:13
  • 2
    $\begingroup$ Greg is correct that generally you shouldn't see an assertion error unless the code itself has a bug assuming they follow standard Python conventions. One option you have before this potential bug is fix is to run python with the -O flag which will, among other things, ignore any assert statements. If there is a bug, this will likely fail later with error related to this condition or just produce nonsensical results, but this may help you to diagnose why this bug is occurring. $\endgroup$
    – Tyberius
    Mar 3, 2022 at 20:52
  • 1
    $\begingroup$ @Gianmarco It would really be ideal if you could copy and paste the error into a code block rather than given us an image which will not be readable by screenreaders used by blind people, and will load slower or not at all on some browsers, and is just in general harder to read. Can you tell us what happened when you tried to run Python with the -O flag? $\endgroup$ Mar 16, 2022 at 0:29

1 Answer 1


Just to aggregate information from the comments, this seems to be a bug in PyTorch Geometric, as typically assertion errors in Python should only be seen on the development side, rather than for an end user.

One possible option you have is to run the script with the -O flag, which will (among other things) ignore assertions. This will likely not fix the problem, but the error message or faulty data you get from removing this check may provide a hint at what specifically is wrong with the code.

You should submit an issue on this repository and/or check that this hasn't already been reported.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .