maciejkula / triplet_recommendations_keras

An example of doing MovieLens recommendations using triplet loss in Keras
Apache License 2.0
421 stars 104 forks source link

Doubt about margin_triplet_loss #6

Closed eshijia closed 7 years ago

eshijia commented 8 years ago

Hi! The code is really a good guild for using keras with triplet prediction. But when I changed the loss function from bpr_triplet_loss to margin_triplet_loss, I found following issue:

AUC before training 0.496249791422
Epoch 0
Train on 49906 samples, validate on 5469 samples
Epoch 1/1
3s - loss: 0.7926 - val_loss: 0.3801
AUC 0.801788456964
Inversions percentage 0.488023404644
Epoch 1
Train on 49906 samples, validate on 5469 samples
Epoch 1/1
3s - loss: 0.3477 - val_loss: 0.3517
AUC 0.806704502864
Inversions percentage 0.381605412324
Epoch 2
Train on 49906 samples, validate on 5469 samples
Epoch 1/1
3s - loss: 0.3233 - val_loss: 0.3500
AUC 0.784859436415
Inversions percentage 0.375022856098
Epoch 3
Train on 49906 samples, validate on 5469 samples
Epoch 1/1
3s - loss: 0.3044 - val_loss: 0.3491
AUC 0.762610735591
Inversions percentage 0.38142256354
Epoch 4
Train on 49906 samples, validate on 5469 samples
Epoch 1/1
3s - loss: 0.2818 - val_loss: 0.3493
AUC 0.746641303774
Inversions percentage 0.386725178278

The Inversions percentage was INCREASING, and the AUC was DECREASING Why? It came to overfitting since the epoch 3?

maciejkula commented 8 years ago

Could be!

eshijia commented 8 years ago

Hmm... I changed the parameters such as batch_size, learning rate many times, but the results were still like what i mentioned. So... how should i use the margin_triplet_loss? Could you give any suggestions? @maciejkula Thanks!

maciejkula commented 8 years ago

To be honest I think I played with it for a while and found it to perform poorly, hence the switch to BPR. There's probably an annoying little mistake in the implementation somewhere.

maciejkula commented 7 years ago

I'll be removing this loss in a PR.