Hi.

I aim to use a RGCN for link predicition so I am following: 5.3 Link Prediction — DGL 0.6.1 documentation

When getting to final step, I dont fully understand the following code:

def compute_loss(pos_score, neg_score):

# Margin loss

n_edges = pos_score.shape[0]

return (1 - pos_score.unsqueeze(1) + neg_score.view(n_edges, -1)).clamp(min=0).mean()

k = 5

model = Model(10, 20, 5, hetero_graph.etypes)

user_feats = hetero_graph.nodes[‘user’].data[‘feature’]

item_feats = hetero_graph.nodes[‘item’].data[‘feature’]

node_features = {‘user’: user_feats, ‘item’: item_feats}

opt = torch.optim.Adam(model.parameters())

for epoch in range(10):

negative_graph = construct_negative_graph(hetero_graph, k, (‘user’, ‘click’, ‘item’))

pos_score, neg_score = model(hetero_graph, negative_graph, node_features, (‘user’, ‘click’, ‘item’))

loss = compute_loss(pos_score, neg_score)

opt.zero_grad()

loss.backward()

opt.step()

print(loss.item())

Those 10,20,5 in the Model arguments… where they come from? Checking the Model function parameters from the model defition I see they are in_features, hidden_features, out_features.

My question is: how can I guess those numbers for my graph?

As I said, my model has the same parameters as the tutorial (with a different graph, obviously).

Thanks