1710.10467 generalized end-to-end loss for speaker verification

简要说明

摘要原文

2017年,作者提出了一个新的损失函数,称为广义损失端到端(GE2E)损失,与之前(2016年)基于元组的端到端(TE2E)丢失函数相比,这使说话人验证模型的训练更加有效。

与TE2E不同,GE2E损失函数以新的方式更新网络参数,其通过关注(emphasizes)在训练过程的各步骤(step)中都难以验证的样本来实现。另外,GE2E损失函数不需要样本选择的初始阶段。 通过这些特性,我们具有新的损失函数的模型将说话人验证的EER降低10%以上,同时将训练时间缩短了60%。

我们还介绍了MultiReader技术,使我们能够进行域自适应,训练出支持多个关键字(Multi keywords)的更准确的模型(即,“ OK Google”和“ Hey Google”)以及多种方言。

容易混淆之处

论文涉及点有些多:

  • 新提出的GE2E Loss应用在Text-independent Speaker Verification(TI-SV)、Text-dependent Speaker Verification(TD-SV)两个领域。
  • 同时Text-dependent领域又提出MultiReader(即多关键字 Multi keywords)
  • 关于GE2E的具体实现,又提出两种:一种是基于Softmax、一种是基于Constract(对比型,关注在训练过程的各步骤中都难以验证的样本)
  • 从而对比实验有这么多。
  • Text-independent领域1个:GE2E vs TE2E vs Softmax;
  • Text-dependent领域4个:(GE2E, TE2E) x (MultiReader, None MultiReader).
  • GE2E中的Softmax(这里所说的Softmax是用在GE2E内部的某个环节)与Contrast对比1个,但这个没结出具体数据。

论文回避之处:

  • 论文摘要中首先强调:“与TE2E不同,GE2E损失函数以新的方式更新网络参数,其通过关注在训练过程的各步骤中都难以验证的样本来实现。”,这个即论文中所说的“Contrasts(对比形式)”的方式,找出负样本中最难区分的。但论文中并未给出GE2E Loss中Softmax与Contrast两种算法具体对比效果,只是简单说:Softmax在TD-SV表现更好,而Contrast在TI-SV中稍微好点。可能是GE2E中的Constrast公式与Triplet Loss太相似了,直接回避。

背景

这里包括几个相关的Loss算子:

  • Triplet Loss
  • Softmax
  • TE2E

Softmax

交叉熵损失函数。直接输出分类的类别概率。

img

Softmax function, a wonderful activation function that turns numbers aka logits into probabilities that sum to one.Softmax function outputs a vector that represents the probability distributions of a list of potential outcomes.

Triplet Loss

2015年FaceNet论文提出Triplet Loss.

img
img

The Triplet Loss minimizes the distance between an anchor and a positive, both of which have the same identity, and maximizes the distance between the anchor and a negative of a different identity.

Triplet Loss解决的问题:

  • 类别数目固定,可以使用基于softmax的交叉熵损失函数。
  • 类别数目是一个变量,可以使用triplet loss,即triplet loss跟类别数量无关。不然,如果类别数很大,比如10k量级的说话人数据集,softmax loss 部分的权重矩阵太大,难以训练。

triplet loss的优势在于细节区分,triplet loss的缺点在于其收敛速度慢,有时不收敛。

Offline triplet

Generate triplets offline every n steps, using the most recent network checkpoint and computing the argmin and argmax on a subset of the data.

根据样本之间的距离,分为:semi-hard triplets,hard triplets与easy triplets三种,选择semi-hard triplets,hard triplets进行训练。

此方法不够高效,因为每过几个epoch,要重新对negative examples进行分类。

Online triplet

Generate triplets online. This can be done by selecting the hard positive/negative exemplars from within a mini-batch.

使用triplet进行分类

FaceNet是特征向量提取器,输出的是一个欧几里得空间向量,随后就可以用各种机器学习算法进行分类。

FaceNet. In this paper we present a system, called FaceNet, that directly learns a mapping from face images to a compact Euclidean space where distances directly correspond to a measure of face similarity. Once this space has been produced, tasks such as face recognition, verification and clustering can be easily implemented using standard techniques with FaceNet embeddings as feature vectors.

前作 Tuple Based End-to-End Loss

2016 End-to-end text-dependent speaker verification. ICASSP

Tuple Based End-to-End Loss:

img
img

Pros

  • Simulates runtime behavior in the loss function
  • Each (N+1)-tuple contains all utterances involved in a verification decision (unlike triplet)

Cons

  • Most tuples are easy - training is inefficient

本文 Generalized End-to-End Loss

2017 Generalized end-to-end loss for speaker verification.

GE2E Loss

img

上图,相同颜色的属于同一类。 [图片上传失败...(image-e1c855-1582508024839)] 是各类的中心。

GE2E loss pushes the embedding towards the centroid of the true speaker, and away from the centroid of the most similar different speaker. [图片上传失败...(image-8a3965-1582508024839)]

Similarit Matrix

相似矩阵

img

Construct a similarity matrix for each batch:

  • Embeddings are L2-normalized:

[图片上传失败...(image-c91b8b-1582508024839)]

  • Centroids:

[图片上传失败...(image-f863af-1582508024839)]

  • Similarity:

[图片上传失败...(image-bd6fbb-1582508024839)]

Softmax vs. Contrast

img

Each row of [图片上传失败...(image-ad80a9-1582508024839)] for [图片上传失败...(image-70f086-1582508024839)] defines similarity between [图片上传失败...(image-3598eb-1582508024839)] and every centroid [图片上传失败...(image-552440-1582508024839)] . We want [图片上传失败...(image-6fb2d8-1582508024839)] to be close to [图片上传失败...(image-f5f189-1582508024839)] and far away from [图片上传失败...(image-63f305-1582508024839)] for [图片上传失败...(image-3ad46f-1582508024839)] .

Softmax与Contrast两个Loss计算方式的对比,以下是作者的实验结果。

  • Softmax: Good for text-independent applications [图片上传失败...(image-ed5237-1582508024839)]
  • Contrast: Good for keyword-based applications. The contrast loss is defined on positive pairs and most aggressive negative pairs [图片上传失败...(image-dd805e-1582508024839)]

这里有个疑问,为何在text-independent任务中Contrast(对比度损失)会比Softmax差呢?

Contrast方法其实是类似Triplet Loss,其Loss计算为:正对和最积极的负对之和。

Trick about centroid

For true speaker centroid, we should exclude the embedding itself. 即计算 [图片上传失败...(image-5601ee-1582508024839)] 时要排除 [图片上传失败...(image-621ff9-1582508024840)] 。

img

To avoid trivial solution: all utterances have same embedding. 即统一成一个公式。

[图片上传失败...(image-698e1b-1582508024840)]

Efficiency estimate

TE2E vs. GE2E

主要思想是,TE2E是一个tuple算一次,而GE2E是基本等于一个批量的tuple,同时放到GPU计算,效率更高。

For TE2E, assume a training batch has: - N speakers - Each speaker has M utterances - P enrollment utterances per speaker

Number of all possible tuples: [图片上传失败...(image-23526b-1582508024840)] Theoretically, one GE2E step is equivalent to [图片上传失败...(image-4186b6-1582508024840)] TE2E steps.

TODO 对这里的具体计算不是很理解。为何能得出 [图片上传失败...(image-3ee240-1582508024840)] 这个数值关系。

对比Triplet Loss

作者认为Triplet Loss的优劣:

  • Pros: Simple, and correctly models the embedding space
  • Cons: Does NOT simulate runtime behavior。

这里的runtime behavior,即语音/人脸验证(verification)场景中的使用流程:

  1. 注册: 注册语音 -> 语音向量 -> 多条语音向量取平均
  2. 验证: 对验证时录制的语音提取特征向量 -> 与注册语音库中的平均向量计算相似度(如Cosine距离) -> 根据设置的阈值在判断是否同一个人。
img

Text-Independent

Text-Independent Speaker Verification

We are interested in identifying speaker based on arbitrary speech Challenge:

  • Length of utterance can vary
  • Unlike keyword-based, where we assume fixed-length (0.8s) for keyword segment

Naive solution: Full sequence training?

  • No batching - very very slow
  • Dynamic RNN unrolling - even slower...

解决方法:Sliding window inference

  • In inference time, we extract sliding windows, and compute per-window d-vector
  • For experiments, we use 1.6s window size, with 50% overlap
  • L2正则化 per-window d-vectors,然后取这些向量的平均值作为这条不定长语音的特征向量。
img

Training

Text-independent Training.

加速训练,同时,充分利用数据。因每批次内部utterances长度相同,从而各utterances 计算时间相同。

img
  • In training time, we need to group utterances by length
  • Extract segments by minimal truncation
  • Form batches of same-length segments

Experiment

Text-independent experiments.

img

Text-dependent

TODO

训练记录

Text-independent

流程分为两个步骤:数据预处理与训练.

音频数据预处理:wav转spectrogram等步骤很耗时,考虑使用GPU来计算,如使用PyTorch audio。

参考

训练耗时参考:

Dataset:

  • LibriSpeech: train-other-500 (extract as LibriSpeech/train-other-500). 500小时音频。
  • VoxCeleb1: Dev A - D as well as the metadata file (extract as VoxCeleb1/wav and VoxCeleb1/vox1_meta.csv). 1200 人
  • VoxCeleb2: Dev A - H (extract as VoxCeleb2/dev). 6000人。

time: trained 1.56M steps (20 days with a single GPU) with a batch size of 64. GPU: GTX 1080 Ti.

训练过程:

img

最终达到的效果:特征向量使用UMAP降维再画图。

img
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,761评论 5 460
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,953评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,998评论 0 320
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,248评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,130评论 4 356
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,145评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,550评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,236评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,510评论 1 291
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,601评论 2 310
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,376评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,247评论 3 313
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,613评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,911评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,191评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,532评论 2 342
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,739评论 2 335

推荐阅读更多精彩内容