I’m following this tutorial for link prediction. In the example, it uses Margin loss on pos_graph (graph with edges) and neg_graph (graph created from random edges):

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

*neg_score/pos_score* contains the dot product of 2 adjacency nodes of *neg_graph* and *pos_graph* respectively.

Why we have to unsqueeze pos_score to 3D and force the broadcasting?

Can we just add the two 2D tensors together, say

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

?

I also want to try cross-entropy loss, is this correct?

`(-torch.log(torch.sigmoid(pos_score_train.unsqueeze(1))) - torch.log(1-torch.sigmoid(neg_score_train.view(n_edges_train, -1)))).mean()`

Thank you!