Closed TryHard-LL closed 2 years ago
Hi @HBU-Lin-Li ,
According to Tab.3, L_entropy can prevent trivial solutions.
Thank you.
Hi @ZhiyuanDang , The consistent loss is same as 'consistency_loss' in SCANLoss?
yes
In code, " def forward(self, anchors, neighbors, anchor_augmented, clustering_results, index, batch_index): """ input:
neighbors: logits for neighbor images w/ shape [b, num_classes]
output:
Loss """
b, n = anchors.size()
anchors_prob = self.softmax(anchors) # 某一样例的一种增强:z1
positives_prob = self.softmax(neighbors) # 该增强的NN:NN(z1)
anchor_augmented_prob = self.softmax(anchor_augmented) # 对应的另一种增强:z2
positives_prob_augmented = anchors_prob[batch_index,:] # 在z2中寻找NN(z1)中idx对应的特征表示z2[idx]
positives_prob = torch.cat([positives_prob, positives_prob_augmented], dim=0)
anchors_prob = torch.cat([anchors_prob, anchor_augmented_prob], dim=0)
# Similarity in output space
similarity = torch.bmm(anchors_prob.view(2 * b, 1, n), positives_prob.view(2 * b, n, 1)).squeeze()
ones = torch.ones_like(similarity)
consistency_loss = self.bce(similarity, ones)
"
It does not match the paper:
“
”
In paper, p is anchor,N_loacl(p) is 'p' neighbor in current bacth and N_pre(p) is pretrain's feature?
In paper, p is anchor,N_loacl(p) is 'p' neighbor in current bacth and N_pre(p) is pretrain's feature?
N_pre(p) is the neighbor from pre-trained features, i.e. positives_prob in the code
大哥,不装了,摊牌了。。。我着实没看明白论文跟代码 的一致性损失是怎么对应的。。 文章中P是指的当前的batch中的某个样例,N_local(p)是当前batch中的近邻,N_pre(p)是预训练特征中的NN,它是batch中的最近邻还是说是样本集中的最近邻呢? 代码中,anchors是指当前的样例,即p,neighbors是指N_pre(p),那anchor_augmented指的是p样例对应的另一种增强得到的样例p_aug吗?那positive_pro_augmented又对应的是什么呢。。。
谢谢大哥!
anchor_augmented是anchors的增强样本。positives_prob_augmented 是anchor的近邻样本的分类输出,对应于N_local(p)。
意思是positives_prob是pretrain得到的一个近邻,positives_prob_augmented是anchor在当前batch中训练时找到的NN?
意思是positives_prob是pretrain得到的一个近邻,positives_prob_augmented是anchor在当前batch中训练时找到的NN?
对的
那论文中的公式处那两个P,是不是应该是一个P,一个P_aug。。。
那论文中的公式处那两个P,是不是应该是一个P,一个P_aug。。。
是的,但是两个p和一个p一个p_aug结果差不多
嗯嗯,好,谢谢您
没事
这个N_pre(p)是预训练时,也在当前的bacth中得到吗
嗯,这个是预训练的时候,整体进行了近邻样本的找寻,然后保存每个anchor的近邻样本的Index,然后在每次训练的时候用dataloader加载进来,具体看看代码就理解了
好嘞,谢谢
Hi, I have a question about the consistent term in the loss. If do so, can't we get a trivial solution? The final clustering result is not a trivial solution,because of using the pretext tasks to learn representations?