> For the complete documentation index, see [llms.txt](https://baozoulin.gitbook.io/neural-networks-and-deep-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://baozoulin.gitbook.io/neural-networks-and-deep-learning/di-wu-men-ke-xu-lie-mo-xing-sequence-models/di-wu-men-kexulie-mo-578b28-sequence-models/di-san-zhou-xu-lie-mo-xing-he-zhu-yi-li-ji-zhi-ff08-sequence-models-and-attention-mechanism/310hong-fa-zi-jian-ce-ff08-trigger-word-detection.md).

# 3.10触发字检测（Trigger Word Detection）

触发字系统的例子如下：

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/28443f8b28afa63adb6cf89ce19c4f6d.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/28443f8b28afa63adb6cf89ce19c4f6d.png)

对于这样的**RNN**结构，要做的就是计算出一个音频片段（an audio clip）的声谱图特征（spectrogram features），得到特征向量$$x^{<1>}$$, $$x^{<2>}$$, $$x^{<3>}$$..，然后把它放到**RNN**中，最后定义目标标签$$y$$

[![](https://2314428465-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Le0cHhI0S0DK8pwlrmD%2F-Le0cKOp1vaxoORIi4ak%2F-Le0cvRn45vabg-xFxgK%2F505import.png?generation=1556953152657139\&alt=media)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/f2da69f9fa6462c8e591e79db452f6c1.png)

假如音频片段中的这一点是某人刚刚说完一个触发字，比如"**Alexa**"，那么在这一点之前，可以在训练集中把目标标签都设为0，在这个点之后把目标标签设为1。假如在一段时间之后，触发字又被说了一次，那么就可以再次在这个点之后把目标标签设为1

不过该算法一个明显的缺点：它构建了一个很不平衡的训练集（**a very imbalanced training set**），0的数量比1多太多

解决方法：在输出变回0之前，多次输出1，或说在固定的一段时间内输出多个1，就稍微提高了1与0的比例，即在音频片段中，触发字刚被说完之后，就把多个目标标签设为1

![](https://2314428465-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Le0cHhI0S0DK8pwlrmD%2F-Le0cKOp1vaxoORIi4ak%2F-Le0cvRqgttlNnza81p0%2F506import.png?generation=1556953152675417\&alt=media)
