如果近几年来有在关注深度学习技术发展的话,一定有听过 attention model 以及 Attention Is All You Need 这篇非常有名的论文,论文的细节这边就不多谈了,网路都可以找的到相当丰富的说明、实作。这边主要要探讨的是如何使用 attention 解决之前提到的输入序列过长会导辨识效果不佳的问题。
Attention 的核心概念可以以下这句话来描述:
Attention: At different steps, let a model "focus" on different parts of the input.
Attention 机制的加入,会让 decoder 在解码的过程中找出输入序列中哪些部分较为重要,因此 encoder 不需要再将输入序列压缩成一固定大小的 context vector。
而 decoder 中的每一个 hidden state 都会有不同的 context vector,也就是说如果输入序列有 N 个音框(frame),就会产生 N 个 context vector。接下来我们用数学式子来表示 attention 的运作过程:
all encoder hidden states:
decoder hidden state at timestamp t :
Attention weights: 将目前时间点 (timestamp) decoder 的 hidden state 对所有 encoder 的 hidden state 进行 score function,再透过 softmax function 计算出 对每一个时间点 的重要程度
其中score function 的运算方式有好几种,包括 dot-product, bilinear, multi-layer perceptron 等
Context vector: 将 attention weights 与 encoder hidden state 进行 weighted sum
完整流程架构可以参考下图:
Seq2seq attention 架构图,图片来源: https://lena-voita.github.io/nlp_course/seq2seq_and_attention.html
今天的内容就到这边,接下来会介绍之前有提到过的end-to-end model 中另一个方常见的方法 -- Connectionist Temporal Classification (CTC)。
参考资料: https://lena-voita.github.io/nlp_course/seq2seq_and_attention.html
<<: [Day02] 程序菜鸟自学C++资料结构 – 简单QA
>>: 自动化 End-End 测试 Nightwatch.js 之踩雷笔记:前言
某些较耗时的工作像是寄信、发通知等,如果卡在处理请求的过程中的话就会造成使用者要多等上数秒才能收到回...
前情提要 在开发 App 的时候,有遇过键盘开启的时候,TextField 却被挡住无法输入的情况吗...
上一回提到广度优先搜寻的步骤是检查图中节点,并将与其相连的节点放入伫列中,再一一检查。 光是这样的文...
温馨鬼故事 - 网购我的爱,我的个资跟着订单出去了 Credit: Drake 故事开始 以下故事纯...
今天的主题是Yolo v2,不过所找到的资料图片可能比较不好理解,有更好的再更新,Yolo v2就是...