rdevon / DIM

Deep InfoMax (DIM), or "Learning Deep Representations by Mutual Information Estimation and Maximization"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to generate 'fake' samples?

jingcx opened this issue · comments

commented

Hi Dr.
Thanks for the paper and code!
I have two questions about postive and negative samples for the JSD estimator mentioned in dim_losses.py

  1. # Compute the positive and negative score. Average the spatial locations. E_pos = get_positive_expectation(u, measure, average=False).mean(2).mean(2) E_neg = get_negative_expectation(u, measure, average=False).mean(2).mean(2)
    While calculating the E_pos and E_neg, all the inputs are the same --- u. I understand that the pos and neg samples should be distinguished before that, while why using the same u as the input here?
  2. E_pos = (E_pos * mask).sum() / mask.sum() E_neg = (E_neg * n_mask).sum() / n_mask.sum()
    Why do this? In code comments Since we have a big tensor with both positive and negative samples, we need to mask., I'm still confused about the mask, and the intention to operate E_neg * n_mask. How to generate neg samples?
    Thanks!

So the first two indices of u corresponds to the N x N scores across the entire batch. The diagonal corresponds to scores from the same image, off-diagonal are scores between two different images from the same batch. Positive samples are from the same image, and we "draw" these by simply pulling out the diagonal component of the positive scores. The negative samples are "drawn" by pulling the off-diagonal elements from the negative scores.

Hope that helps.

commented

Thanks for your explanation!