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

关于参与计算loss_soft的特征 #7

Closed
hewumars opened this issue Nov 10, 2020 · 9 comments
Closed

关于参与计算loss_soft的特征 #7

hewumars opened this issue Nov 10, 2020 · 9 comments

Comments

@hewumars
Copy link

hewumars commented Nov 10, 2020

loss_soft = (- F.softmax(sim_diff_label[:,:,0].contiguous().view(B,-1)/self.temp[gen], dim=1).detach() * log_sim_diff).mean(0).sum()

这里为什么只是取区域特征相似度得分图的sim_diff_label[:,:,0]第一行来计算loss?参与计算的只有[B,diff_pos_num,9]。

bc_features.data.copy_(torch.cat(features))

另外图片太多内存会爆,所以只取了1万类,query每类1张,gallery每类4张,是否需要把pos_num=4,neg_num=10?

@yxgeee
Copy link
Owner

yxgeee commented Nov 10, 2020

  1. 因为在我的实验中, query不做region划分, 只有第一行对应的是query原图与positive的原图及region的相似度

@yxgeee
Copy link
Owner

yxgeee commented Nov 10, 2020

  1. 我不清楚你的query和gallery具体如何划分, 你的query和gallery是否会有类别重叠? 如果你每张query最多只有4个positive, 那么pos_num最大为4, neg_num的话不一定是10, 可以就性能和GPU memory来做具体限制.

@yxgeee
Copy link
Owner

yxgeee commented Nov 10, 2020

另外,如果你在reID上做实验的话,其实我建议在一个reID的codebase上加上这个region的loss. 因为这个code针对的是街景图,无论是图像预处理,还是training scheme都跟reID上最适合的不一样. netvlad也不一定在reID上能收敛的好.

@hewumars
Copy link
Author

好的,感谢。我做局部特征的检索,我试验下直接用区域-区域之间是否可以通过这种无监督方式来做。netVLAD刚好也可以用提局部特征。

@hewumars
Copy link
Author

还想请教下,sync_gather的两种模式,内存和显存占用有大概统计下极限吗? True的时候11G显存超,False的时候128GB内存超。query+gallery大概5w多张样本。

@yxgeee
Copy link
Owner

yxgeee commented Nov 10, 2020

超内存和超显存的代码位置应该不一样. 为false的时候哪句话超的内存?

@hewumars
Copy link
Author

True: dist.all_gather(all_features, features)显存超
False:bc_features.data.copy_(torch.cat(features))内存超

@hewumars
Copy link
Author

bc_features = torch.cat(features).cuda(gpu)
for k in range(world_size):
  bc_features.data.copy_(torch.cat(features))
  dist.broadcast(bt_features,k)      

True显存超可能没法解决,False内存超这里有点疑问?
bc_features = torch.cat(features).cuda(gpu)这里定义在gpu上面,为啥copy_的时候是内存在涨?
copy_是不是应该移到循环外面?

@yxgeee
Copy link
Owner

yxgeee commented Nov 11, 2020

这里features太多的时候确实可能超,应该是代码上有缺陷.
有人做了修改(#6) ,可以参考一下

@yxgeee yxgeee closed this as completed Dec 21, 2020
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