Hi, I’m trying to implement a heterogeneous graph for node classification using my own dataset and I am referring to this documentation https://docs.dgl.ai/en/0.8.x/guide/training-node.html#guide-training-node-classification
This is how I have defined my heterograph.
hetero_graph = dgl.heterograph({
('customer', 'purchase', 'item'): (torch.tensor(cust_id),torch.tensor(item_id))
})
hetero_graph.nodes['customer'].data['feature'] = cust_node_features
hetero_graph.nodes['item'].data['feature'] = item_node_features
hetero_graph.nodes['customer'].data['label'] = labels
no_of_users = hetero_graph.num_nodes('customer')
no_of_purchases = hetero_graph.num_edges()
hetero_graph.nodes['customer'].data['train_mask'] = torch.zeros(no_of_users, dtype=torch.bool).bernoulli(0.6)
hetero_graph.edges['purchase'].data['train_mask'] = torch.zeros(no_of_purchases, dtype=torch.bool).bernoulli(0.6)
The output of this is.
Graph(num_nodes={‘customer’: 42, ‘item’: 175},
num_edges={(‘customer’, ‘purchase’, ‘item’): 193},
metagraph=[(‘customer’, ‘item’, ‘purchase’)])
The RGCN model is
RGCN(
(conv1): HeteroGraphConv(
(mods): ModuleDict(
(purchase): GraphConv(in=10, out=20, normalization=both, activation=None)
)
)
(conv2): HeteroGraphConv(
(mods): ModuleDict(
(purchase): GraphConv(in=20, out=2, normalization=both, activation=None)
)
)
)
I’m using the RGCN class defined in the above link. When I run the below lines, I’m getting an empty string {} for h_dict variable. The output of node_features is attached
#no_of_cust_node_features = 10
model = RGCN(no_of_cust_node_features, 20, 2, hetero_graph.etypes)
cust_feats = hetero_graph.nodes['customer'].data['feature']
item_feats = hetero_graph.nodes['item'].data['feature']
labels = hetero_graph.nodes['customer'].data['label']
train_mask = hetero_graph.nodes['customer'].data['train_mask']
node_features = {'customer': cust_feats, 'item': item_feats}
h_dict = model(hetero_graph, {'customer': cust_feats, 'item': item_feats})
h_dict
Can someone please help me to understand why I’m getting an empty string instead of some values?