Unverified Commit 4507bebc authored by Quan (Andy) Gan's avatar Quan (Andy) Gan Committed by GitHub
Browse files

add compute_loss example in link prediction user guide (#2487)

parent 0c2a2ea1
......@@ -137,6 +137,11 @@ above.
.. code:: python
def compute_loss(pos_score, neg_score):
# an example hinge loss
n = pos_score.shape[0]
return (neg_score.view(n, -1) - pos_score.view(n, -1) + 1).clamp(min=0).mean()
model = Model(in_features, hidden_features, out_features)
model = model.cuda()
opt = torch.optim.Adam(model.parameters())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment