Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate 'fake' samples? #31

Closed
jingcx opened this issue Sep 5, 2019 · 2 comments
Closed

How to generate 'fake' samples? #31

jingcx opened this issue Sep 5, 2019 · 2 comments

Comments

@jingcx
Copy link

jingcx commented Sep 5, 2019

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!
@rdevon
Copy link
Owner

rdevon commented Sep 7, 2019

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.

@jingcx
Copy link
Author

jingcx commented Sep 10, 2019

Thanks for your explanation!

@jingcx jingcx closed this as completed Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants