hidasib / GRU4Rec

GRU4Rec is the original Theano implementation of the algorithm in "Session-based Recommendations with Recurrent Neural Networks" paper, published at ICLR 2016 and its follow-up "Recurrent Neural Networks with Top-k Gains for Session-based Recommendations". The code is optimized for execution on the GPU.
Other
747 stars 222 forks source link

BPR loss implementation question #33

Open msemikin opened 5 years ago

msemikin commented 5 years ago

Hi, I have a question about the mini-batch sampled BPR loss. The code is as follows:

def bpr(self, yhat, M):
    return T.cast(T.mean(-T.log(T.nnet.sigmoid(gpu_diag_wide(yhat).dimshuffle((0, 'x'))-yhat))), theano.config.floatX)

Do I understand correctly, that the score for the positive item is also considered as one of the negative scores? Positive score is not filtered from the negative scores list. Sigmoid of 0 difference between positive and negative here will be 0.5 and negative log contribution to loss will be 0.7 from the positive score itself.