WeightedLinkPredictBCELossFunc
- class graphstorm.model.WeightedLinkPredictBCELossFunc(*args, **kwargs)
Bases:
GSLayerLoss function for link prediction tasks using binary cross entropy loss with weights.
The
torch.nn.functional.binary_cross_entropy_with_logitsis used to compute the loss. The loss function is defined as:\[loss = - w\_e [ y \cdot \log score + (1 - y) \cdot \log (1 - score) ]\]where
yis 1 for a positive edge and 0 for a negative edge.scoreis the score value ofecomputed by the score function,w_eis the weight of an edgee, which is defined as:\[\begin{split}w\_e = \left \{ \begin{array}{lc} 1, & \text{ if } e \in G, \\ 0, & \text{ if } e \notin G \end{array} \right.\end{split}\]where
Gis the training graph.