3、multi-head self-attention\attention
single self-attention
multi-head self attention
本质上就是多个single self-attettnion的堆叠,每个都享有不同的权重,最后再及进行concat
multi-head attention
4. 堆积多头注意力变成transformer
encoder ,用到了stacked self-attentions
每个block层的输入和输出的shape是一样的
decoder: 用到了stacked 的attentions
一个decoder block块的形状
可以缩放成以下
输入是两个序列,输出是一个序列。左边的输入序列是encoder的输出,右边的输入是前一个block的输出。