RElbers/info-nce-pytorch

should I add parameters of InfoNCE to optimizer for optimizing?

Closed this issue · 3 comments

I use pip install the infoGAN-pytorch, I know Mutual information is estimated by network. And when I use the code, should I add the parameters of class InfoNCE to the optimizer for optimizing, or I can directly use the function and it will give me the correct loss? Thank you!

Hello. Sorry for the late reply. InfoNCE loss has no parameters, so you don't need to add it the the optimizer.

The negative samples are calculated from the batch of positive samples
Say you have a batch of N pairs of positive and query samples. Then the similarity between all combinations of positive and query is calculated, giving a N by N matrix. The diagonal of this matrix have the values for the positive pairs. The values outside of the diagonal are considered the negative samples. This means that to have enough negative samples, the batch-size also needs to be large.