机器学习和深度学习-- 李宏毅(笔记于个人理解)Day 21

Day 21 Self- Attention

选修部分

image-20240417184829593 image-20240417190658276 image-20240417190749226

学完自适应 再回来看看

image-20240417194732455

Sequence Labling

image-20240419164301252

假如我们现在有一个需要读完全部句子才能解的问题, 那么red window 就需要变得是最大的(最长的句子);

其实这里大家有没有想过,这个玩意儿就是个卷积网络CNN,所谓的window 就是卷积核

image-20240419164705272

what is self Attention?

image-20240419165946852

image-20240419180752296

how self-attention work

image-20240419180922799

image-20240419181037670

image-20240419181213748

主要考虑 Dot -product

image-20240419181410909

image-20240419181437037实际操作自己也要做关联计算qk

image-20240419181707806

如果b1 和 v2 比较接近的话,那么我们就说这a1 和a2 比较像

image-20240419181955949

b1 --b4 是同时产生的

image-20240419182801592矩阵运算的角度
image-20240419182940352

image-20240419183015516

你也可以不做softmax(Relu 也行)

image-20240419183214224

(小bug是 a_head 换成 ')

image-20240419183312687

image-20240419183338095

Multi-head -self-attention

image-20240419183549015

image-20240419183609932

image-20240419183623280

Positional Encoding

image-20240419183803012

image-20240419183904640

hand - crafted (s to s 的规则使得不会超过位置信息)

can learned from data

image-20240419184036200

这里感觉不到数学的巧妙,只是感到了工程的流水线的简洁和高效

Applicantions

image-20240419184218973

image-20240419184405845

image-20240419184459715image-20240419184506080

Self -attention vs CNN

image-20240419184707039image-20240419184718389

弹性较大,数据较小的时候容易过拟合

提问:

  1. 我们知道 fc 和cnn差不多(无非是fc更宽一些,如果你把cnn当初fc做的话有可能丢失位置信息,或可能需要postion encode),那么问你为什么不把windows变得很大去卷积呢?
  2. 如果说像老师说的
  3. 无法得知最长的sequerence
  4. 参数量大(这里不太明白参数量大在什么地方)

Self-Attention vs RNN

image-20240419185221168

image-20240419185314799

image-20240419190227419

  1. 这里和我理解的差不多,就是特征彼此离得太远有点记不住了
  2. RNN 无法进行并行计算

image-20240419190258144

Self - Attention for Graph

image-20240419190414972

image-20240419190452180可以做智能知识图谱哎,相关性度量;this is one type of Graph Neural Network(GNN)

最近更新

  1. TCP协议是安全的吗?

    2024-04-20 22:50:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-20 22:50:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-20 22:50:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-20 22:50:02       20 阅读

热门阅读

  1. Android笔记: mkdirs失败,不生效怎么办

    2024-04-20 22:50:02       37 阅读
  2. 计算机网络——应用层(4)DHCP和套接字编程

    2024-04-20 22:50:02       13 阅读
  3. Led驱动程序

    2024-04-20 22:50:02       13 阅读
  4. Springboot整合物联网IOT的MQTT协议

    2024-04-20 22:50:02       13 阅读
  5. 推荐算法之协同过滤

    2024-04-20 22:50:02       14 阅读
  6. python中的并发编程-进程、线程2

    2024-04-20 22:50:02       14 阅读
  7. 数据库-Redis(18)

    2024-04-20 22:50:02       14 阅读
  8. wsl + ubuntu + pycups + mqtt 远程打印入门

    2024-04-20 22:50:02       16 阅读
  9. docker-002常用命令

    2024-04-20 22:50:02       12 阅读