分享一下偶然看到的这几个函数的pytorch实现。
里面有ContrastiveLoss,BatchHardSoftMarginTripletLoss,BatchSemiHardTripletLoss ........虽然还是少几个相关的损失函数
今年年初和去年年初做的一个东西里要用到这几个东西,但是搜了很久,翻来翻去,代码实现很难找到。不得已自己写了不少例如online batch hard mining之类的东西,为花掉的时间感到心痛。不过这个库不少代码四月份才上传上去。 https://github.com/UKPLab/sentence-transformers/blob/master/sentence_transformers/losses/BatchHardTripletLoss.py
去年在语音数据上做的一些实验,在数据量不大的情况下,l2-softmax之类的损失函数还是不错的。使用这些损失函数在其他任务上预训练,得到的embedding还是挺好的(用在做voice-verification等领域)。triplet loss之类的,训练需要不少技巧,虽然有论文报告说经过仔细调试结果是相当不错。但是挺难处理,挺难训练,两个项目在使用triplet loss时都遇到了一定的困难,模型不收敛之类的,当时也没解决。不知道时自己写的代码错了还是咋的。
度量学习(Metric Learning)中几个Ranking Loss Functions的实现
JinLonghua Aug 20, 2020, 10:11:05 PM
Last Modified: Aug 20, 2020, 10:11:05 PM
Views: 4.4K
[[total]] comments
Post your comment-
[[item.time]]
[[item.user.username]] [[item.floor]]Floor-
[[cc.time]]
[[cc.user.username]] #[[cc.room]] -
- «
- 1
- ...
- [[i]]
- ...
- »
-
- Click to load more...
- Post your comment