besskge.loss.SampledSoftmaxCrossEntropyLoss
- class besskge.loss.SampledSoftmaxCrossEntropyLoss(n_entity, loss_scale=1.0)[source]
The sampled softmax cross-entropy loss (see [JCMB15] and [CJM+22]).
Initialize the sampled softmax cross-entropy loss.
- Parameters:
n_entity (
int
) – The total number of entities in the knowledge graph.loss_scale (
float
) – seeBaseLossFunction
- get_negative_weights(negative_score)
Construct weights of negative samples, based on their score.
- Parameters:
negative_score (
Tensor
) – : (batch_size, n_negative) Scores of negative samples.- Return type:
- Returns:
shape: (batch_size, n_negative) if
BaseLossFunction.negative_adversarial_sampling
else () Weights of negative samples.