eggie5 / RankNet

Learning to Rank from Pair-wise data
http://www.eggie5.com/130-learning-to-rank-siamese-network-pairwise-data
55 stars 10 forks source link

Why labels are all 1? #1

Closed pengzhendong closed 5 years ago

pengzhendong commented 5 years ago

I wonder whether it would cause the unbalanced dataset and predict all pairs to 1.

eggie5 commented 5 years ago

Imbalance doesn't apply in this cause b/c we are working w/ permutations of pairs not pointwise labels. The loss is: L(X;theta)=log(siqmoid(f(A)-f(B)) so as you can see there really are no labels (there is no y in that loss equation). I only add fake 1 labels and binary x-entropy for it to work in Keras, b/c all Keras requires all model losses to be a function of x and y!

pengzhendong commented 5 years ago

Thanks. So during predicting, do I just use create_base_network to get the score of any example and sort them by scores?

eggie5 commented 5 years ago

Yes, but use an instance (trained) of the base_network instead of creating a new one, like in cell 7 of the notebook. The base network is the "Scoring Function" and then it's called a score-and-sort approach.

pengzhendong commented 5 years ago

OK, thank you very much. 👍