geffy / tffm

TensorFlow implementation of an arbitrary order Factorization Machine
MIT License
780 stars 176 forks source link

Support for Bayesian Personalized Ranking #46

Open jerry-rubikloud opened 5 years ago

jerry-rubikloud commented 5 years ago

Hi there, I'm thinking of contributing codes for BPR. What is the best way to extend the code to handle this optimization in your opinion?

geffy commented 5 years ago

Hi @jerry-rubikloud ! I think that we need to implement 2 components: 1) BPRSampler. It will generate pairs from source data and put them into batch. Example: for N pairs we will have a batch with N2 samples (`2 i-th are _winners_,2 i + 1`-th are losers) 2) BRPLoss. It will take expanded batch output ([2N, 1]), convert it to pairs ([N, 2]) and calculate resulting loss. This design seems to be easy for implementation and allows to keep FM core routine unchanged