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
关于tripletangularmarginloss.py中的负样本类距离loss计算absolut_loss_an #3110
Comments
这个loss的计算方式是cosin相似度,而不是欧式距离,代码中变量命名方式可能存在误导。如果是使用欧式距离的话,确实应该是问题中提到写法,而使用cosine相似度的话,写法正好是相反的。对于欧式距离,anchor与negative距离越大越好,对于cosine相似度,anchor与negative相似越小越好 |
感谢您的回复! |
对于cosine相似度,anchor与negative相似越小越好,所以距离越小的loss应该越大 |
你好,可能我的疑问没有清楚的被表达。 |
对于cosine相似度,anchor与negative相似越小越好,但是注意这里的dist_an越大代表越相似,从你的描述看来好像是认为dist_an越小则anchor与negative越相似,可能是这里理解反了。 |
你好,对于negative应该相似越低越好,那么为何absolut_loss_an越低(负样本越不相似越好)loss的值越大呢?效果越好loss不应该越小么 |
不好意思,前面可能说错了,主要还是得看这段代码: |
absolut_loss_an = dist_an - self.an_value 此处absolut_loss_an应该是anchor与negative相似度的loss。 |
刚刚我们确认了一下,这里的作用不是为了增加负样本的loss,而是去筛选出相似度很低的样本作为负样本,增加相似度低的样本的loss权重,以让模型对于负样本会提升更多的关注度 |
感谢您的耐心回复! 另外如果有此处筛选可以提升负样本关注度的相关论文可以麻烦分享一下么? |
absolut_loss_an > 0说明该负样本的相似度较高。作为负样本,我们更应该关注那些相似度较低的样本 |
相似度高的negative才是难以判别的样本,不是更应该优化相似度高的negative?怎么会去更关注相似度低的negative?negative的相似度需要尽可能小 @changdazhou |
这里是为了让相似度低的负样本距离更远,相似度高的正样本距离更近,可以看下这个文档的loss部分,TripletAngularMarginLoss是基于Triplet loss的百度自研损失函数,所以没有论文可供参考。 |
你好,请问在PaddleClas/ppcls/loss
/tripletangularmarginloss.py中
L108的absolut_loss_an计算,对于dist_an<an_value的值为何是置为1而不是置为0?
dist_an应该是小于an_value的,为什么在计算loss时对于小于an_value的dist_an给到了更大的loss?
为何不使用如下计算:absolut_loss_an = paddle.where(absolut_loss_an > 0,absolut_loss_an,paddle.zeros_like(absolut_loss_an))?
期待您的解答,谢谢
欢迎您使用PaddleClas并反馈相关问题,非常感谢您对PaddleClas的贡献!
提出issue时,辛苦您提供以下信息,方便我们快速定位问题并及时有效地解决您的问题:
a. 具体操作系统,如Linux/Windows/MacOS
b. Python版本号,如Python3.6/7/8
c. CUDA/cuDNN版本, 如CUDA10.2/cuDNN 7.6.5等
The text was updated successfully, but these errors were encountered: