yukilulu/CaC

Some questions about CaC code

Closed this issue · 6 comments

Firstly thanks for sharing the code to the community. I encountered some questions in my code reading process.
I don't understand the following code . Could you explain it in more detail?

        #‘idx_match_in_cur’ is the index corresponding to this x
        idx_match_in_cur = match[0]

        # ‘idx_match_project_cur’: The nearest neighbor of x is equal to the index corresponding to the tar_idx
        idx_match_project_cur = match[-1]
        # first_k = match[1]
        weight = torch.ones(bs, bs).cuda()
        weight[idx_match_in_cur, idx_match_project_cur] = 0.0

Thanks!

"The index of each sample is for the entire dataset. 'match' is a Boolean matrix used to determine whether their nearest neighbors in the current training mini-batch have samples 'x', noted that 'x' is contained in 'tar_idx', meaning the current sample indexes. Finally, the matrix 'weight' is detailed in section 3.6 of the paper. I hope this clears up any doubts."

May I ask if you have Art_ list.txt and so on

Linzsd commented

What is the meaning of match[0] and match[1]?

What is the meaning of match[0] and match[1]?

Match[-1] means that the nearest neighbor of x is equal to the index corresponding to the tar_idx, so, these samples are consider similar samples too, and should be excluded in the negative pooling.

Match [0] and match [-1] are used to mask these negative samples, and these samples are similar, as described in detail in section 3.6 of the paper, "Finding the Truly Negative Pair".

Linzsd commented

What is the meaning of match[0] and match[1]?

Match[-1] means that the nearest neighbor of x is equal to the index corresponding to the tar_idx, so, these samples are consider similar samples too, and should be excluded in the negative pooling.

Match [0] and match [-1] are used to mask these negative samples, and these samples are similar, as described in detail in section 3.6 of the paper, "Finding the Truly Negative Pair".

What is the difference between match[0] and match[1] ... match[-1] and can you explain their meaning more specifically

What is the meaning of match[0] and match[1]?

Match[-1] means that the nearest neighbor of x is equal to the index corresponding to the tar_idx, so, these samples are consider similar samples too, and should be excluded in the negative pooling.
Match [0] and match [-1] are used to mask these negative samples, and these samples are similar, as described in detail in section 3.6 of the paper, "Finding the Truly Negative Pair".

What is the difference between match[0] and match[1] ... match[-1] and can you explain their meaning more specifically

I forgot an important command in the first version, and now I have made corresponding changes: adding torch. where (match>0) to index it. In order to better describe the meaning of each dim in the tuple 'match', I have updated the corresponding explanation in (tar_adaptation. py);

At the same time, I uploaded a simple example in the file "A simple example of tuple" match ". ipynb", which I believe can help you better understand match.