Hi community,
I have a dimensionality problem when trying to do link prediction between user-node and item-node. I took inspiration from this guide: [DGL Guide](5.3 Link Prediction — DGL 0.6.1 documentation)
Currently, the item-node has 5 attributes whereas the user-node only has 3 attributes. This keeps giving me dimensionality problem with the well-known error message: “mat1 and mat2 shapes cannot be multiplied”. If I do dummy features of same dimension, the problem is not present.
My question is if it is possible to do link prediction between two different node-types with different number of attributes and if so, how? I see that some posts recommend recommends using MLP to align dimensionality, but I can not find anywhere describing why and how this solves the issue.
I am quite new to GNN, so could be I am missing some essential knowledge within the area.
Thanks in advance.
Current code, which works:
hetero_graph = g
k = 5
g.nodes['member'].data['features'] = torch.randn(7000, 5)
g.nodes['course'].data['features'] = torch.randn(88, 5)
user_feats = hetero_graph.nodes['member'].data['features'].float()
item_feats = hetero_graph.nodes['course'].data['features'].float()
model = Model(5, 10 , 5, hetero_graph.etypes)
node_features = {'member': user_feats, 'course': item_feats}
opt = torch.optim.Adam(model.parameters())
for epoch in range(10):
negative_graph = construct_negative_graph(hetero_graph, k, ('member', 'm_attends', 'course'))
pos_score, neg_score = model(hetero_graph, negative_graph, node_features, ('member', 'm_attends', 'course'))
loss = compute_loss(pos_score, neg_score)
opt.zero_grad()
loss.backward()
opt.step()
print(loss.item())