LinkPredictContrastiveLossFunc
- class graphstorm.model.LinkPredictContrastiveLossFunc(temp=1.0)
Bases:
GSLayerContrastive Loss function for link prediction tasks.
The positive and negative scores are computed through a score function as:
\[score = f(<src, rel, dst>)\]And we treat a score as the distance between
srcanddstnodes under relationrel.In contrastive loss, we assume one positive pair <src, dst> has K corresponding negative pairs <src, neg_dst1>, <src, neg_dst2> …. <src, neg_dstk>. When we compute the loss of <src, dst>, we follow the following equation:
\[loss = -log(exp(pos\_score)/\sum_{i=0}^K exp(score_i))\]where score includes both positive score of <src, dst> and negative scores of <src, neg_dst0>, … <src, neg_dstk>.
Parameters
- temp: float
Temperature value.