sp-monte-carlo
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
###### tags: `generative models` `comments and reviews` `sampling` `one-offs` # Forward-Backward Markov Models for Density Estimation **Overview**: The following exposition aims to describe the methods presented in these two papers ([1](http://proceedings.mlr.press/v37/sohl-dickstein15.html), [2](https://hojonathanho.github.io/diffusion/)) in terms of standard Monte Carlo techniques. ## Introduction Consider the task of fitting a generative model $P_\theta (x)$ to data $x^1, \ldots, x^N \sim P_{\text{Data}}$. Fitting complex distributions to data "in one shot" is often challenging, and so it is often considered useful to develop some sort of bridging strategy, i.e. to transform noise into samples in a guided way. The approach I will describe here starts by constructing a bridge from the distribution of our samples towards a known, tractable target, and then seeks to form an approximation to the backward path. ## Forward Markov Model Fix an "easy" target distribution $\gamma$ on the state space of interest. Specify a Markov transition semigroup $( K_t )_{t \geqslant 0}$ which generates an ergodic Markov process which converges in law to $\gamma$ as $t \to \infty$. For sufficiently nice initial distributions $\mu$ and sufficiently large $T$, it should then hold that $\mu K_T \approx \gamma$. With this in mind, define $\mu_t = P_{\text{Data}} K_t$. Under sensible assumptions, it holds that $\mu_0 = P_{\text{Data}}$, $\mu_\infty = \gamma$, and for large $T$, one expects that $\mu_T \approx \gamma$. This will be the basis of our (approximate) bridge between $P_{\text{Data}}$ and $\gamma$. ## Backward Markov Model Let the time-reversal of $( K_t )_{t \geqslant 0}$ with respect to $\gamma$ be given by $( L_t )_{t \geqslant 0}$, i.e. for any $t > 0$, \begin{align} \gamma (dx) K_t (x \to dy) = \gamma (dy) L_t (y \to dx). \end{align} For $0 = t_0 < t_1 < \ldots < t_K = T < \infty$, consider now the joint distribution \begin{align} Q (dx_{0:K}) \triangleq P_{\text{Data}} (dx_0) \cdot \prod_{0 < k \leqslant K} K_{t_k - t_{k-1}} (x_{k - 1} \to dx_k). \end{align} Note that if $P_{\text{Data}} \ll \gamma$, then one can also write \begin{align} Q (dx_{0:K}) = \gamma (dx_K) \cdot \prod_{0 \leqslant k < K} L_{t_{k+1} - t_k} (x_{k + 1} \to dx_k) \cdot \frac{d P_{\text{Data}}}{d \gamma} (x_0). \end{align} ## Twisted Backward Markov Model In practice, we should expect $P_{\text{Data}}$ and $\gamma$ to be quite singular with respect to one another. However, by modifying the $L$ kernels appropriately, it should be possible to guide the $x_0$-marginal of the process closer to $P_{\text{Data}}$. Suppose that for $K > k \geqslant 0$, we define kernels $L_{t_{k+1} - t_k}^{\theta, t_{k+1}, t_k} (x_{k+1} \to d x_k)$ which are absolutely continuous with respect to $L_{t_{k+1} - t_k} (x_{k + 1} \to dx_k)$ with explicitly-available Radon-Nikodym derivative, and from which we can sample. One can then define \begin{align} P_\theta (dx_{0:K}) = \gamma (dx_K) \cdot \prod_{0 \leqslant k < K} L_{t_{k+1} - t_k}^{\theta, t_{k+1}, t_k} (x_{k + 1} \to dx_k). \end{align} For example, if $( K_t )_{t \geqslant 0}, ( L_t )_{t \geqslant 0}$ are the transition operators of a diffusion, then one could define the $L^\theta$ by adding an additional drift term to the SDE. Note that the process in $P_\theta$ need not be stationary, and indeed, it should not be. ## Concrete Example Let $\gamma (dx) = \mathcal{N} ( dx | 0, I_d )$, and let $K = L$ be the Ornstein-Uhlenbeck semigroup which corresponds to the diffusion \begin{align} dX_t = - X_t dt + \sqrt{2} dW_t. \end{align} Then \begin{align} L_\delta (x \to dy) = \mathcal{N} \left( dy | \exp(-\delta) x, \left(1 - \exp(-2\delta) \right) I \right), \end{align} and so one might define \begin{align} L_{t_{k+1} - t_k}^{\theta, t_{k+1}, t_k} (x_{k + 1} \to dx_k) &= \mathcal{N} \left( dx_k |\mu^\theta_k ( x_{k+1}, t_{k+1} ), \left(1 - \exp(-2\delta) \right) I \right) \\ \mu^\theta_k ( x_{k+1}, t_{k+1} ) &= \exp(-(t_{k+1} - t_k)) x_{k+1} + (t_{k+1} - t_k) \beta^\theta (x_{k+1}, t_{k+1} ) \end{align} where $\beta^\theta (x, t)$ is a parametrised "extra drift" function. This can be viewed as a discretisation of \begin{align} dX_t = \left( -X_t - \beta^\theta (x, t) \right)dt + \sqrt{2} dW_t \end{align} backwards in time (note the "sign error" in $\beta$). The $L^\theta$ can be sampled from because they are still conditionally Gaussian, and the Radon-Nikodym derivatives are available due to Girsanov's theorem. ## Training Objective One approach to training these models is by maximum likelihood, i.e. \begin{align} \max_{\theta \in \Theta} \sum_{i = 1}^N \log P_\theta ( x^i ), \end{align} where $P_\theta$ here denotes the $x_0$-marginal of the joint $P_\theta$ distribution. Of course, this marginal is not analytically available in general, and so a standard trick is to apply Importance Sampling / Jensen's inequality to note that \begin{align} \log P_\theta ( x_0 ) = \log \left( \int_{x_{1:K}} P_\theta ( dx_{0:K} ) \right) \geqslant \mathbf{E}_{Q ( dx_{1:K} | x_0)} \left[ \log \left( \frac{P_\theta ( x_{0:K})}{ Q (x_{1:K} | x_0 )} \right) \right] = \mathcal{L} (\theta) \end{align} where the ratio should be interpreted as a suitable modification of a Radon-Nikodym derivative. In [2](https://hojonathanho.github.io/diffusion/), the authors optimise $\mathcal{L}$ with respect to $\theta$. They also use the following additional simplification \begin{align} \mathbf{E}_{Q ( dx_{1:K} | x_0)} \left[ \log \left( \frac{P_\theta ( x_{0:K})}{ Q (x_{1:K} | x_0 )} \right) \right] &= \mathbf{E}_{Q ( dx_{K} | x_0 )} \left[ \log \left( \frac{ P_\theta (x_K)}{ Q(x_K | x_0 )} \right) \right] \\ &+ \sum_{K > k > 0} \mathbf{E}_{Q ( dx_k, dx_{k+1} | x_0)} \left[ \log \left( \frac{ P_\theta (x_k | x_{k + 1})}{ Q(x_k | x_{k + 1}, x_0 )} \right) \right] \\ &+ \mathbf{E}_{Q ( dx_1 | x_0)} \left[ \log P_\theta ( x_0 | x_1 ) \right]. \end{align} Note that since $Q$ is a Gaussian process with known covariance, the conditional probabilities of $Q$ are known exactly. Moreover, the $(K - 1)$ terms in the sum can be expressed in terms of KL divergences between Gaussian measures, and so can be estimated and optimised with low variance. Note also that the first term is independent of $\theta$, as $P_\theta (dx_K) = \gamma (dx_K)$. There are similarities here with the training of variational autoencoders, though note that in a VAE, one would also train the $Q$. Here, the $Q$ remains fixed, though in principle, one could also adapt it to be closer to the path of $P$, provided the appropriate conditional distributions remain tractable. Some other links between diffusion-based generative models, variational inference, and control problems are elucidated in [1](http://proceedings.mlr.press/v99/tzen19a.html), [2](https://arxiv.org/abs/1905.09883). Note also that this final training scheme is not "true" maximum likelihood, as an imperfect surrogate objective is maximised instead. In principle, "true" maximum likelihood is possible by (stochastic) gradient descent on $\theta$ though this could be challenging. Successful estimation of $\nabla_\theta \log P_\theta (x)$ might require some combination of importance sampling, sequential Monte Carlo, or Markov Chain Monte Carlo, at each step.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully