简体   繁体   English

如何在我的项目中实现三元组损失?

[英]How to implement triplet loss in my project?

Im doing a project on speaker recognition and I have data set of audio files which from them I take feature of sound ( array of 1x13 ) as input and as output I pick a random integer for each speaker ( let's say speaker 1 - output = 1 speaker 2 output = 2...)我正在做一个关于说话人识别的项目,我有音频文件的数据集,从中我将声音特征(1x13 数组)作为输入和输出,我为每个扬声器选择一个随机整数(假设扬声器 1 - 输出 = 1扬声器 2 输出 = 2...)

I was offered to use triplet loss in order to achieve better accuracy but I don't understand how we implement it in tensor-flow ( there is no examples at all )我被提议使用三元组损失以获得更好的准确性,但我不明白我们如何在张量流中实现它(根本没有例子)

From what I understood until now, I take 2 positive and one negative values for each speaker ( for example 2 features of 2 audios files of the same speaker, and one feature of synthetic audio file of another speaker which I will create with wavenet)从我到现在的理解,我为每个扬声器取 2 个正值和一个负值(例如,同一扬声器的 2 个音频文件的 2 个特征,以及我将使用 wavenet 创建的另一个扬声器的合成音频文件的一个特征)

But what I do with this features in order to achieve the triplet loss, meaning how I really implement it using tensor flow但是我用这个特性做了什么以实现三元组损失,这意味着我如何使用张量流来真正实现它

The Triplet loss function working is explained in below steps. Triplet 损失函数的工作在以下步骤中进行了解释。

Training Data:训练数据:
Like you said, you need to have triplet for each training sample, Anchor,Positive,Negetive .就像你说的,每个训练样本都需要有三元组, Anchor,Positive,Negetive

Architecture of the model:模型架构:

The idea is to have 3 identical networks having the same neural net architecture and they should share weights.这个想法是让 3 个相同的网络具有相同的神经网络架构,并且它们应该共享权重。

在此处输入图片说明

Model Learning:模型学习:

The model not only learned to formulate clusters for different classes at the same time, but it's also successful in projecting similar-looking data into their neighborhood region.该模型不仅学会了同时为不同类别制定集群,而且还成功地将外观相似的数据投影到其邻域区域。 In the case of classification architecture, the model tries to learn a decision boundary between a pair of classes, but the model doesn't take care of the integrity between similar and dissimilar data within a class.在分类架构的情况下,该模型尝试学习一对类之间的决策边界,但该模型不考虑类内相似和不同数据之间的完整性。

You can follow this link and this link which has the implementation for the triplet loss on TensorFlow, you can follow the same architecture for your data with some changes in it.您可以点击此链接以及此链接,该链接在 TensorFlow 上实现了三元组损失,您可以遵循相同的数据架构,并对其进行一些更改。

Hope this helps you, Happy Learning!希望对你有帮助,祝学习愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM