當(dāng)前位置:
首頁(yè) >
attention mechanis 的数学理解
發(fā)布時(shí)間:2025/4/5
43
豆豆
生活随笔
收集整理的這篇文章主要介紹了
attention mechanis 的数学理解
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
參考鏈接
attention其實(shí)就是一個(gè)加權(quán)求和
import numpy as np import tensorflow as tfa=np.array((list(range(3*4)))).reshape((3,4))*1.0 b=a+3.0 katten=tf.keras.layers.Attention()([a, b])print('keras attention=',katten)從算法本質(zhì)上理解attention ,就是三次矩陣運(yùn)算
weight=a@b.T weight1=tf.nn.softmax(weight) attent=weight1@bprint('my attention=',attent) keras attention= tf.Tensor( [[11. 12. 13. 14.][11. 12. 13. 14.][11. 12. 13. 14.]], shape=(3, 4), dtype=float32) my attention= tf.Tensor( [[11. 12. 13. 14.][11. 12. 13. 14.][11. 12. 13. 14.]], shape=(3, 4), dtype=float64)總結(jié)
以上是生活随笔為你收集整理的attention mechanis 的数学理解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ubuntu 输入法问题:显示繁体
- 下一篇: sql substr切割字符串