李宏毅-机器学习2021春-3


1 Classification

将Class用one-hot vector表示

image-20211018171800758

回归与分类的区别:

image-20211018172028857

softmax:

image-20211018204256372

Loss的计算:

image-20211018212606688

2 Convolutional Neural Network (CNN)

为Image Classification设计的网络。

默认Image大小为100*100。

  • Receptive field(感受野):图像的一个局部特征

image-20211024191947238

  • 共享参数:w1,w2是相同的

image-20211024192949816

image-20211024193059114

receptive field + sharing parameteres = convolutional layer

  • Convolutional layer:由一堆Filter组成,Filter捕捉图片里的pattern。
  • Feature Map:图片经过Convolution layer得到的结果

image-20211024193844714

  • Pooling—Max Pooling

    • 没有参数需要学习

      image-20211024194148311

  • Spatial Transformer Layer:解决CNN无法面对放大和旋转的问题

3 Self-attention

3.1 背景

当输入是多组向量时,输出的情况:

  • 每一个向量都有一个label(sequence labeling),此处可以用self-attention
  • 整个sequence有一个label
  • 模型自己决定输出长度(seq to seq)

image-20211019220621798

3.2 原理

Self-attention的输出$b^1$,既代表$a^1$,又代表$a^1$和$a^2$、$a^3$的关系。

image-20211019222613111

解释得到$b^1$的过程:

  • image-20211019221902427
  • ●代表dot-product;此处不一定要用soft-max
  • image-20211019223447121

完整过程:

  • image-20211019223658109
  • image-20211019223737019

3.3 Multi-head Self-attention

寻找多种相关性。

image-20211020223303153

image-20211020223323098

image-20211020223339129

Positional Encoding

为每一个位置设置一个位置向量$e^i$。

image-20211020223531893

3.4 其它变种

在语音辨识中,用于输入的数据很长,可以用Trancated Self-attention,只考虑每一段音频和周围的一定长度内的音频的关系。

Self-attention同样可以用于图片。

。。。

Self-attention vs CNN

。。。

Self-attention vs RNN

。。。

Self-attention for Graph

。。。