Replies: 1 comment
-
As you correctly pointed out, you will need unique one-hot encoded features to apply offset = 1
for i in range(x.size(-1)):
x[:, i] *= offset
offset = int(x[:, i].max()) + 1
x = x.sum(dim=-1)
_, x = torch.unique(x, return_inverse=True) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
I apologize for the banality of the question, but I am a rookie in the world of geometric deep learning and I am learning to use PyG. I would like to run the Weisfeiler-Lehman kernel on a dataset that I generated, where the data looks like:
Data(x=[9, 9], edge_index=[2, 18], edge_attr=[18, 2], y=[1])
And the node feature matrix (
x
) is a torch FloatTensor who looks like:`tensor([[6., 1., 0., 4., 0., 3., 0., 0., 0.],
[8., 2., 0., 3., 0., 0., 0., 0., 0.],
[6., 3., 0., 3., 0., 0., 0., 0., 0.],
[8., 1., 0., 3., 0., 0., 0., 0., 0.],
[6., 2., 0., 3., 0., 1., 0., 0., 0.],
[6., 2., 0., 3., 0., 1., 0., 0., 0.],
[7., 3., 0., 3., 0., 0., 0., 1., 0.],
[6., 2., 0., 4., 0., 2., 0., 1., 0.],
[6., 2., 0., 4., 0., 2., 0., 1., 0.]])`
Now my question is: is there any way to transform this into a matrix consisting of just 1's and 0's, like the x-matrix of the ENZYMES dataset used in example (https://github.com/pyg-team/pytorch_geometric/blob/master/examples/wl_kernel.py)? Without carrying out this transformation the code returns the AssertionError
(x.sum(dim=-1) == 1).sum() == x.size(0)
. Thanks you all!Beta Was this translation helpful? Give feedback.
All reactions