X

Cheatsheet of Latex Code for Most Popular Machine Learning Equations

Navigation

In this blog, we will summarize the latex code for most popular machine learning equations, including multiple distance measures, generative models, etc. There are various distance measurements of different data distribution, including KL-Divergence, JS-Divergence, Wasserstein Distance(Optimal Transport), Maximum Mean Discrepancy(MMD) and so on. We will provide the latex code for machine learning models in the following sections. We will also provide latex code of Generative Adversarial Networks(GAN), Variational AutoEncoder(VAE), Diffusion Models(DDPM) for generative models in the second section.

    Generative Models

  • Generative Adversarial Networks(GAN)

    Equation


    Latex Code
            \min_{G} \max_{D} V(D,G)=\mathbb{E}_{x \sim p_{data}(x)}[\log D(x)]+\mathbb{E}_{z \sim p_{z}(z)}[\log(1-D(G(z)))]
            
    Explanation

    GAN latex code is illustrated above. See paper for more details Generative Adversarial Networks

  • Variational AutoEncoder(VAE)

    Estimating the Log-likelihood and Posterior
    Equation


    Latex Code
            \log p_{\theta}(x)=\mathbb{E}_{q_{\phi}(z|x)}[\log p_{\theta}(x)] \\
            =\mathbb{E}_{q_{\phi}(z|x)}[\log \frac{p_{\theta}(x,z)}{p_{\theta}(z|x)}] \\
            =\mathbb{E}_{q_{\phi}(z|x)}[\log [\frac{p_{\theta}(x,z)}{q_{\phi}(z|x)} \times \frac{q_{\phi}(z|x)}{p_{\theta}(z|x)}]] \\
            =\mathbb{E}_{q_{\phi}(z|x)}[\log [\frac{p_{\theta}(x,z)}{q_{\phi}(z|x)} ]] +D_{KL}(q_{\phi}(z|x) || p_{\theta}(z|x))\\
            
    Explanation

    Evidence Lower Bound
    Equation


    Latex Code
                \mathbb{L}_{\theta,\phi}(\mathbf{x})=\mathbb{E}_{q_{\phi}(\mathbf{z}|\mathbf{x})}[\log p_{\theta}(\mathbf{x},\mathbf{z})-\log q_{\phi}(\mathbf{z}|\mathbf{x}) ]
            
    Explanation

    Reparameterization trick
    Equation

    Latex Code
                z = \mu + \epsilon \cdot \sigma
            
    Explanation

    VAE latex code is illustrated above. See paper for more details Auto-Encoding Variational Bayes

  • Diffusion Models(DDPM)

    Explanation

    See paper Denoising Diffusion Probabilistic Models for more details. See reference of the following blogpost https://lilianweng.github.io/posts/2021-07-11-diffusion-models/

    1.1 Forward Process
    Equation


    Latex Code
                q(x_{t}|x_{t-1})=\mathcal{N}(x_{t};\sqrt{1-\beta_{t}}x_{t-1},\beta_{t}I) \\q(x_{1:T}|x_{0})=\prod_{t=1}^{T}q(x_{t}|x_{t-1})
            
    1.2 Forward Process Reparameterization Trick
    Equation


    Latex Code
                x_{t}=\sqrt{\alpha_{t}}x_{t-1}+\sqrt{1-\alpha_{t}} \epsilon_{t-1}\\=\sqrt{\alpha_{t}\alpha_{t-1}}x_{t-2} + \sqrt{1-\alpha_{t}\alpha_{t-1}} \bar{\epsilon}_{t-2}\\=\text{...}\\=\sqrt{\bar{\alpha}_{t}}x_{0}+\sqrt{1-\bar{\alpha}_{t}}\epsilon \\\alpha_{t}=1-\beta_{t}, \bar{\alpha}_{t}=\prod_{t=1}^{T}\alpha_{t}
            
    1.3 Reverse Process


    Latex Code
                p_\theta(\mathbf{x}_{0:T}) = p(\mathbf{x}_T) \prod^T_{t=1} p_\theta(\mathbf{x}_{t-1} \vert \mathbf{x}_t) \\
                p_\theta(\mathbf{x}_{t-1} \vert \mathbf{x}_t) = \mathcal{N}(\mathbf{x}_{t-1}; \boldsymbol{\mu}_\theta(\mathbf{x}_t, t), \boldsymbol{\Sigma}_\theta(\mathbf{x}_t, t))
            
    1.4 Reverse Process Variational Lower Bound


    Latex Code
                \begin{aligned}
                - \log p_\theta(\mathbf{x}_0) 
                &\leq - \log p_\theta(\mathbf{x}_0) + D_\text{KL}(q(\mathbf{x}_{1:T}\vert\mathbf{x}_0) \| p_\theta(\mathbf{x}_{1:T}\vert\mathbf{x}_0) ) \\
                &= -\log p_\theta(\mathbf{x}_0) + \mathbb{E}_{\mathbf{x}_{1:T}\sim q(\mathbf{x}_{1:T} \vert \mathbf{x}_0)} \Big[ \log\frac{q(\mathbf{x}_{1:T}\vert\mathbf{x}_0)}{p_\theta(\mathbf{x}_{0:T}) / p_\theta(\mathbf{x}_0)} \Big] \\
                &= -\log p_\theta(\mathbf{x}_0) + \mathbb{E}_q \Big[ \log\frac{q(\mathbf{x}_{1:T}\vert\mathbf{x}_0)}{p_\theta(\mathbf{x}_{0:T})} + \log p_\theta(\mathbf{x}_0) \Big] \\
                &= \mathbb{E}_q \Big[ \log \frac{q(\mathbf{x}_{1:T}\vert\mathbf{x}_0)}{p_\theta(\mathbf{x}_{0:T})} \Big] \\
                \text{Let }L_\text{VLB} 
                &= \mathbb{E}_{q(\mathbf{x}_{0:T})} \Big[ \log \frac{q(\mathbf{x}_{1:T}\vert\mathbf{x}_0)}{p_\theta(\mathbf{x}_{0:T})} \Big] \geq - \mathbb{E}_{q(\mathbf{x}_0)} \log p_\theta(\mathbf{x}_0)
                \end{aligned}
            
    1.5 Reverse Process Variational Lower Bound Decomposition Multiple KL-Divergence

    $$begin{aligned}L_\text{VLB} &= \mathbb{E}_{q(\mathbf{x}_{0:T})} \Big[ \log\frac{q(\mathbf{x}_{1:T}\vert\mathbf{x}_0)}{p_\theta(\mathbf{x}_{0:T})} \Big] \\&= \mathbb{E}_q \Big[ \log\frac{\prod_{t=1}^T q(\mathbf{x}_t\vert\mathbf{x}_{t-1})}{ p_\theta(\mathbf{x}_T) \prod_{t=1}^T p_\theta(\mathbf{x}_{t-1} \vert\mathbf{x}_t) } \Big] \\&= \mathbb{E}_q [\underbrace{D_\text{KL}(q(\mathbf{x}_T \vert \mathbf{x}_0) \parallel p_\theta(\mathbf{x}_T))}_{L_T} + \sum_{t=2}^T \underbrace{D_\text{KL}(q(\mathbf{x}_{t-1} \vert \mathbf{x}_t, \mathbf{x}_0) \parallel p_\theta(\mathbf{x}_{t-1} \vert\mathbf{x}_t))}_{L_{t-1}} \underbrace{- \log p_\theta(\mathbf{x}_0 \vert \mathbf{x}_1)}_{L_0} ]\end{aligned}$$
    Latex Code
                \begin{aligned}L_\text{VLB} &= \mathbb{E}_{q(\mathbf{x}_{0:T})} \Big[ \log\frac{q(\mathbf{x}_{1:T}\vert\mathbf{x}_0)}{p_\theta(\mathbf{x}_{0:T})} \Big] \\&= \mathbb{E}_q \Big[ \log\frac{\prod_{t=1}^T q(\mathbf{x}_t\vert\mathbf{x}_{t-1})}{ p_\theta(\mathbf{x}_T) \prod_{t=1}^T p_\theta(\mathbf{x}_{t-1} \vert\mathbf{x}_t) } \Big] \\&= \mathbb{E}_q [\underbrace{D_\text{KL}(q(\mathbf{x}_T \vert \mathbf{x}_0) \parallel p_\theta(\mathbf{x}_T))}_{L_T} + \sum_{t=2}^T \underbrace{D_\text{KL}(q(\mathbf{x}_{t-1} \vert \mathbf{x}_t, \mathbf{x}_0) \parallel p_\theta(\mathbf{x}_{t-1} \vert\mathbf{x}_t))}_{L_{t-1}} \underbrace{- \log p_\theta(\mathbf{x}_0 \vert \mathbf{x}_1)}_{L_0} ]\end{aligned}
            
    1.6 Reverse Process Variational Lower Bound Loss Function


    Latex Code
                \begin{aligned}
                L_\text{VLB} &= L_T + L_{T-1} + \dots + L_0 \\
                \text{where } L_T &= D_\text{KL}(q(\mathbf{x}_T \vert \mathbf{x}_0) \parallel p_\theta(\mathbf{x}_T)) \\
                L_t &= D_\text{KL}(q(\mathbf{x}_t \vert \mathbf{x}_{t+1}, \mathbf{x}_0) \parallel p_\theta(\mathbf{x}_t \vert\mathbf{x}_{t+1})) \text{ for }1 \leq t \leq T-1 \\
                L_0 &= - \log p_\theta(\mathbf{x}_0 \vert \mathbf{x}_1)
                \end{aligned}
            

Comments


  • DriverRox 2025-05-02 10:27

    Партнер по бизнесу подсказал интересное толкование сновидений. Кремация проведена согласно требованиям. Благодарим за профессионализм.


  • ParisMug 2025-05-12 15:06

    Общие рекомендации к средствам очистки http://chimtechservice.ru/postavka Промывка и ремонт теплообменников http://chimtechservice.ru/teploobmenniki При необходимости специализированное подразделение компании выполнит доставку, монтаж теплообменника и пуск его в эксплуатацию http://chimtechservice.ru/postavka Чтобы обеспечить правильный уход за теплообменным оборудованием, обращайтесь за профессиональной помощью Компания предлагает полный комплекс соответствующих услуг http://chimtechservice.ru/postavka Профессионализм подрядчика определяется по следующим критериям: Данный метод актуален для промывки теплообменника с сильной степенью загрязнений, когда обычной промывки недостаточно http://chimtechservice.ru/teploobmenniki В процессе работы по очистке теплообменника аппарат разбирается, и пластины очищаются вручную с помощью специальных составов http://chimtechservice.ru/teploobmenniki После обратной сборки специалисты проверяют герметичность и качество работы оборудования http://chimtechservice.ru/teploobmenniki Сроки выполнения разборной очистки теплообменника зависит от уровня загрязнения и состояния оборудования http://chimtechservice.ru/postavka


  • AaronBoday 2025-05-12 19:32

    от 3 шт https://ats-mxm.ru/katalog/ip-ats-ericsson-lg-ipecs-ucp 24500 ? от 3 шт https://ats-mxm.ru/resheniya/sistema-palatnoj-svyazi-otdeleniya-bolnitsy 15200 ? юр https://ats-mxm.ru/katalog/domofony-usiliteli-ggs-adaptery-i-drugoe-oborudovanie лица 12429 ? Цветная антивандальная вызывная видеопанель с CCD камерой 800 ТВл и ИК диодами, не светящими в глаза https://ats-mxm.ru/katalog/ustrojstva-operativnoj-i-proizvodstvennoj-svyazi/uots-60-4-rm-panasonic Корпус выполнен из качественно обработанной металического сплава и поликарбоната https://ats-mxm.ru/katalog/aksessuary-2 Врезной монтаж https://ats-mxm.ru/katalog/mxm120-300-500/ip500p Монтажная коробка в комплекте https://ats-mxm.ru/katalog/shkafy-nastennye/shnr-100 Рабочая температура: -40 – +65 °С https://ats-mxm.ru/katalog/dopolnitelnye-interfejsnye-platy/plata-2-portov-interfejsa-isdn-bri-4-kanala-briu2 Класс защищенности: IP65 https://ats-mxm.ru/katalog/ibp-stabilizatory/smart-station-1000 Двухсторонняя связь https://ats-mxm.ru/katalog/ustroistva-i-terminaly/maksifon-mxf-dsm-t Размеры: 180?101?45 мм https://ats-mxm.ru/katalog/provodnye-telefonnye-apparaty/vp-17p Объектовая станция https://ats-mxm.ru/katalog/tsifrovye-telefonnye-stantsii-ericsson-lg-ipecs-emg80-s-podderzhkoj-ip/bazovyj-blok-ats-ericsson-lg-emg80-ksua Домофон – переговорное устройство с возможность открытия замка, которое обеспечивает должный уровень безопасности и ограничивает попадание на территорию жилого дома, загородного участка, производственного объекта посторонних лиц https://ats-mxm.ru/katalog/ustroistva-i-terminaly/maksifon-mxf-ds-tt-v Его устанавливают в квартирах, домах, офисах компаний, на производстве и в других местах https://ats-mxm.ru/katalog/ustroistva-i-terminaly/maksifon-mxf-dsmm-lo


  • Zacharyrok 2025-05-27 15:30

    Подскажите где найти лучшие рецепты со всего мира: от классических блюд, которые согревают душу, до современных кулинарных шедевров, которые впечатляют даже самых взыскательных гурманов - https://hexagon.vn/2023/06/22/harnessing-the-power-of-social-media-for-business-growth - рецепты в домашних условиях

Write Your Comment

Upload Pictures and Videos