cnclabs/codes.tpr.rec

Is the argument "-num_negative" effective?

JonathanChen1002 opened this issue · 3 comments

Hi, I would like to ask several questions about negative sampling:

  1. I found the argument "-num_negative" while running tpr, but I couldn't find any reference in the code. Is it effective while training?
  2. If I want to change the weight of negative sampling, what is simplest way to implement?

Thank you

Hi,

  1. I just update the code making it work: https://github.com/cnclabs/codes.tpr.rec/blob/master/hub/tpr.cpp#L81
  2. please try to modify this: https://github.com/cnclabs/codes.tpr.rec/blob/master/src/sampler/vc_sampler.cpp#L39
    the negative_sampler can be used for negative sampling

In my understanding, current training procedure is:

  1. draw a user and relative item i
  2. draw another positive item j and relative word w (by item i)
  3. uniformly draw a item j' and corresponding relative word w' as negative pair
  4. update embedding for j, j', w, w'
  5. repeat 2~4 five(-num_negative) times
  6. update embedding for u, i

If I want to change the weight of negative sampling, I think I need to feed the weight into negative_sampler, and call draw_a_negative in tpr.cpp. Am I correct?

yes, it seems no problem