AI/机器学习常用公式的LaTex代码汇总

本文整理了常见的AI和机器学习公式,包括RNNs、注意力机制、Transformer、GAN、VAE等模型的LaTeX表示,以及激活函数、损失函数、评估指标的相关公式,适用于论文和博客写作。资料已同步到GitHub,欢迎大家补充和改进。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在写AI/机器学习相关的论文或者博客的时候经常需要用到LaTex的公式,然而作为资深“伸手党”的我在网上搜索的时候,居然没有找到相关现成资源@-@

那么,我就把自己经常会遇到的公式整理如下,以NLP和一些通用指标函数为主。有需要的可以自取,当然发现有问题或者遗漏的也欢迎指正和补充。(我同步到了Github上( https://github.com/blmoistawinde/ml_equations_latex ),欢迎提issue和PR,当然还有star~)

Classical ML Equations in LaTeX

A collection of classical ML equations in Latex . Some of them are provided with simple notes and paper link. Hopes to help writings such as papers and blogs.

Better viewed at https://blmoistawinde.github.io/ml_equations_latex/

Model

RNNs(LSTM, GRU)

encoder hidden state h t h_t ht at time step t t t
h t = R N N e n c ( x t , h t − 1 ) h_t = RNN_{enc}(x_t, h_{t-1}) ht=RNNenc(xt,ht1)

decoder hidden state s t s_t st at time step t t t

s t = R N N d e c ( y t , s t − 1 ) s_t = RNN_{dec}(y_t, s_{t-1}) st=RNNdec(yt,st1)

h_t = RNN_{enc}(x_t, h_{t-1})
s_t = RNN_{dec}(y_t, s_{t-1})

The R N N e n c RNN_{enc} RNNenc, R N N d e c RNN_{dec} RNNdec are usually either

Attentional Seq2seq

The attention weight α i j \alpha_{ij} αij, the i i ith decoder step over the j j jth encoder step, resulting in context vector c i c_i ci

c i = ∑ j = 1 T x α i j h j c_i = \sum_{j=1}^{T_x} \alpha_{ij}h_j ci=j=1Txαijhj

α i j = exp ⁡ ( e i j ) ∑ k = 1 T x exp ⁡ ( e i k ) \alpha_{ij} = \frac{\exp(e_{ij})}{\sum_{k=1}^{T_x} \exp(e_{ik})} αij=k=1Txexp(eik)exp(eij)

e i k = a ( s i − 1 , h j ) e_{ik} = a(s_{i-1}, h_j) eik=a(si1,hj)

c_i = \sum_{j=1}^{T_x} \alpha_{ij}h_j

\alpha_{ij} = \frac{\exp(e_{ij})}{\sum_{k=1}^{T_x} \exp(e_{ik})}

e_{ik} = a(s_{i-1}, h_j)

a a a is an specific attention function, which can be

Bahdanau Attention

Paper: Neural Machine Translation by Jointly Learning to Align and Translate

e i k = v T t a n h ( W [ s i − 1 ; h j ] ) e_{ik} = v^T tanh(W[s_{i-1}; h_j]) eik=vTtanh(W[si1;hj])

e_{ik} = v^T tanh(W[s_{i-1}; h_j])
Luong(Dot-Product) Attention

Paper: Effective Approaches to Attention-based Neural Machine Translation

If s i s_i si and h j h_j hj has same number of dimension.

e i k = s i − 1 T h j e_{ik} = s_{i-1}^T h_j eik=si1Thj

otherwise

e i k = s i − 1 T W h j e_{ik} = s_{i-1}^T W h_j eik=si1TWhj

e_{ik} = s_{i-1}^T h_j

e_{ik} = s_{i-1}^T W h_j

Finally, the output o

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值