triplet loss keyword spotting 代码
以 google speech commands为例
Vygon, Roman, and Nikolay Mikhaylovskiy. “Learning efficient representations for keyword spotting with triplet loss.” International Conference on Speech and Computer. Springer, Cham, 2021.ciations:12
github: Learning Efficient Representations for Keyword Spotting with Triplet Loss
https://www.codeleading.com/article/61624664033/
https://bindog.github.io/blog/2019/10/23/why-triplet-loss-works/
github人脸检测:https://github.com/kuaikuaikim/DFace
/home/data/yelong/triplet_loss_kws/loss/utils.py
1 | def RandomNegativeTripletSelector(margin, cpu=False): return FunctionNegativeTripletSelector(margin=margin, |
找triplet三元组:
方法:找出所有同类a,p对,而a,n对根据不同策略选出不同a,n,我这里用的随机,就是在所有d(a,p)-d(a,n)+margin大于0的组合中,随机选一个a,n作为三元组(a,p,n)的n index
1 |
|
计算triplet loss
1 | def __init__(self, margin, triplet_selector): |