ContrastiveSeg
ContrastiveSeg copied to clipboard
About args n_view,max_samples
Hello! Your work is outstanding! I did a detailed research on both the paper and the code. There are a lot of questions that I don’t understand:
- I want to ask first about the loss_contrast.py Can you explain the meaning of max_samples and n_views in the hard_anchor_sampling function?
- If you apply this method to small samples, can the hard_anchor_sampling step be omitted? I hope you can explain in more detail,many thanks!
Hi,Thanks for your interest.
- As given in the following line,
max_samples
is the maximum number of samples for all classes, andn_views
is the average number for each class. https://github.com/tfzhou/ContrastiveSeg/blob/7be326ae9127a847558584eac489d4858adf7cb1/lib/loss/loss_contrast.py#L47 - You can also try to find some hard anchors (which are misclassified), no matter how many samples you have.
Thank you for your prompt reply! Then I have corresponding questions and look forward to your help to explain: classes = [] total_classes = 0 for ii in range(batch_size): this_y = y_hat[ii] this_classes = torch.unique(this_y) this_classes = [x for x in this_classes if x != self.ignore_label] this_classes = [x for x in this_classes if (this_y == x).nonzero().shape[0] > self.max_views]
classes.append(this_classes)
total_classes += len(this_classes)
In your code, if there are the same categories in different batches, will there be duplicate statistics in the result of total_classes? Hope you can solve my confusion.
What do you mean for "duplicate statistics"? p.s. If you have many questions, please also feel free to compile them together here at one time.
Hello! Your work is outstanding! I did a detailed research on both the paper and the code. There are a lot of questions that I don’t understand:
- Can you explain the meaning of
self.max_views
in the hard_anchor_sampling function? And why need(this_y == x).nonzero().shape[0] > self.max_views
? - In my project, some labels only have a little targat pixels, specially resized to the size of embedding, so the
total_classes==0
situation may be happened, so thatfeats_
is None andself._contrast
function can not run. - I want to ask about the
class HRNet_W48_MEM
ofhrnet.py
:def _momentum_update_key_encoder(self): for param_q, param_k in zip(self.encoder_q.parameters(), self.encoder_k.parameters()): param_k.data = param_k.data * self.m + param_q.data * (1. - self.m)
Can you explain the meaning ofself.encoder_k
?I am sorry that I did not find its definition. I hope you can explain in more detail,many thanks!