# bpr_loss¶

paddle.fluid.layers.loss. bpr_loss ( input, label, name=None ) [source]

Bayesian Personalized Ranking Loss Operator

This operator belongs to pairwise ranking loss. Label is the desired item. The loss at a given point in one session is defined as:

$Y[i] = 1/(N[i] - 1) * \sum_j{\log(\sigma(X[i, Label[i]]-X[i, j]))}$

Parameters
• input (Variable|list) – a 2-D tensor with shape [N x D], where N is the batch size and D is the number of positive classes and negative classes This input is not probability but logits.

• label (Variable|list) – the ground truth which is a 2-D tensor. label is a tensor<int64> with shape [N x 1].

• name (str|None) – A name for this layer(optional). If set None, the layer will be named automatically. Default: None.

Returns

A 2-D tensor with shape [N x 1], the bpr loss.

Examples

import paddle.fluid as fluid