pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
20.62k stars 3.58k forks source link

Meta data #4452

Open faizan1234567 opened 2 years ago

faizan1234567 commented 2 years ago

🐛 Describe the bug

I defined HAN class for heterogeneous graph learning on the IMDB dataset. However, when I create metadata and pass it on to the HAN class it gives me " init() got multiple values for argument 'metadata' ". The code is shown here.

path = osp.join(osp.dirname(osp.realpath('file')), '../../data/IMDB')

metapaths = [[('movie', 'actor'), ('actor', 'movie')], [('movie', 'director'), ('director', 'movie')]] transform = T.AddMetaPaths(metapaths= metapaths, drop_orig_edges= True, drop_unconnected_nodes= True) dataset = IMDB(path, transform= transform) data = dataset[0]

class HAN(nn.Module): def init(self, in_channels: Union[int, Dict[str, int]], out_channels: int, hidden_channels = 128, heads=8): super().init()

self.HanConv = HANConv(in_channels, hidden_channels, heads, 
                       dropout = 0.6, metadata=data.metadata())
self.lin = nn.Linear(hidden_channels, out_channels)

def forward(self, x_dict, edge_index_dict): x = self.HanConv(x_dict, edge_index_dict) x = self.lin(x['movie']) return x model = HAN(in_channels= -1, out_channels= 3) print(model)

please help me fix this bug.

Environment

rusty1s commented 2 years ago

Can you define via HANConv(in_channels, hidden_channels, heads=heads, …)? This should fix the issue.

faizan1234567 commented 2 years ago

Sure let me check

faizan1234567 commented 2 years ago

Now it gives me this error. han_Conv

faizan1234567 commented 2 years ago

I am using this example from PyTorch geometric examples.

faizan1234567 commented 2 years ago

Moreover, I am running my code on Google Colab.

faizan1234567 commented 2 years ago

please see this as well. han_conv1

faizan1234567 commented 2 years ago

Ok issue resolved. I used HANConv(in_channels, hidden_channels, heads = heads, dropout = 0.6, metadat = data.metadata())... this solved the issue. Thank you for your support