info-nce-pytorch icon indicating copy to clipboard operation
info-nce-pytorch copied to clipboard

Minimizing this loss function will minimize or maximize mutual information?

Open geolvr opened this issue 2 years ago • 3 comments

I'm confused about this. NCEloss can determine the lower bound of mutual information. In this implementation, should NCEloss be minimized in order to increase mutual information?

geolvr avatar Jul 29 '22 08:07 geolvr

A lower NCE loss means a higher lower bound of the mutual information. So minimizing the NCE loss will maximize the (lower bound of the) mutual information.

RElbers avatar Aug 01 '22 13:08 RElbers

In my actual pytorch training, I take NCEloss as part of my loss function and observe the mutual information value calculated by sklearn's API (sklearn.metrics.mutual_info_score) during the training process. However, I found that as the NCE loss decreases, the mutual information also decreases. I can't think of a reason to explain this.

geolvr avatar Aug 09 '22 08:08 geolvr

I think I figured it out. This method provided by sklearn cannot be used to calculate mutual information between continuous variables, thus leading to wrong results.

geolvr avatar Aug 11 '22 13:08 geolvr