Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimension (Mis)matching - What's the correct usage of DeepSnap Heterogeneous Graph Convolution? #18

Open
yrf1 opened this issue Mar 9, 2021 · 1 comment

Comments

@yrf1
Copy link

yrf1 commented Mar 9, 2021

I'm sorry I didn't find a good example code or documentation online that I can follow.

In example code below, how come the GNN didn't require a dimension 200/350/800 input?

from deepsnap.hetero_gnn import HeteroConv, HeteroSAGEConv, forward_op, loss_op
from deepsnap.hetero_graph import HeteroGraph
import networkx as nx
conv1 = {}
conv1[("n1","e0","n0")] = HeteroSAGEConv(800,600,200)
conv1[("n1","e1","n1")] = HeteroSAGEConv(350,600,350)
conv1 = HeteroConv(conv1)
G = nx.DiGraph()
G.add_node("n0", node_type="n0", node_feature=\
                    torch.zeros((1)).float())
G.add_node("n1", node_type="n1", node_feature=\
                    torch.zeros((1)).float())
G.add_edge("n0", "n1", edge_type="e1")
G = HeteroGraph(G)
G = conv1(G, G.edge_index)
@anniekmyatt
Copy link

Hello! I am just a user of this code base, rather than involved in the development but I might be able to help? Can I ask where your example code comes from?

To create a HeteroSAGEConv layer, the inputs are:

conv1[("src_node","link_label","dst_node")] = HeteroSAGEConv(num_features_src_type,hidden_dimension, num_features_dst_type)

where num_features_src_type is the number of features for the node type of your source node and num_features_dst_type is the number of features on the destination node.

That means that for the layer you define in your example, for conv1[("n1","e1","n1")], I would have expected

conv1[("n1","e1","n1")] = HeteroSAGEConv(800,600,800), if your desired hidden dimension is 600 and the number of features on node type n1 is 800, as it suggests from the definition of conv1[("n1","e0","n0")]. I might be able to help more if you explain a bit more what you are trying to achieve in your example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants