Error in Heterogeneous graph by applying the PYG model #8150
Unanswered
amalislam675
asked this question in
Q&A
Replies: 1 comment 6 replies
-
You need to call via h = self.conv1(x_dict, edge_index_dict, edge_weight_dict) |
Beta Was this translation helpful? Give feedback.
6 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.
-
I try to apply the GCN2Conv model within HeteroGNN, I found this below mentioned error, can you tell how to fix? With the same code, If I apply GCNConv from PYG, it works fine. Here, need to add initial features, that's why, I am giving the x_dict two times as residual feature.
import numpy as np
import torch
from torch_geometric.data import HeteroData
Random data just to show how store values of nodes work
authors = torch.rand((10,8))
papers = torch.rand((10,8))
authors_y = torch.rand(10)
Random data just to show how store values of edges work
write_from = torch.tensor(np.random.choice(10, 15, replace = True))
write_to = torch.tensor(np.random.choice(10, 15, replace=True))
write = torch.concat((write_from, write_to)).reshape(-1,15).long()
Random dat justo to show how store values of edges work
cite_from = torch.tensor(np.random.choice(10, 15, replace=True))
cite_to = torch.tensor(np.random.choice(10, 15, replace=True))
cite = torch.concat((cite_from, cite_to)).reshape(-1,15).long()
edge_weight1 = torch.rand(15)
edge_weight1 = edge_weight1.unsqueeze(-1)
edge_weight2 = torch.rand(15)
edge_weight2 = edge_weight2.unsqueeze(-1)
from torch_geometric.data import HeteroData
data = HeteroData()
data['author'].x = authors
data['paper'].x = papers
data['author', 'writes', 'author'].edge_index=write
data['paper', 'cited_by', 'paper'].edge_index=cite
data['author', 'writes', 'author'].edge_weight= edge_weight1
data['paper', 'cited_by', 'paper'].edge_weight= edge_weight1
print(data)
import torch
import torch_geometric.transforms as T
from torch_geometric.nn import HeteroConv, GCN2Conv, Linear
class HeteroGNN(torch.nn.Module):
def init(self, hidden_channels, out_channels):
super().init()
Error
Traceback (most recent call last):
File "/123/PYG/example1_1.py", line 87, in
out = model(data.x_dict, data.edge_index_dict, data.edge_weight_dict)
File "/123/PYG/.conda/envs/foo/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/123/PYG/example1_1.py", line 67, in forward
h = self.conv1(x_dict, x_dict, edge_index_dict, edge_weight_dict)
File "/123/pyg/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/123/pyg/lib/python3.10/site-packages/torch_geometric/nn/conv/hetero_conv.py", line 106, in forward
src, rel, dst = edge_type
ValueError: too many values to unpack (expected 3)
Beta Was this translation helpful? Give feedback.
All reactions