Giter Site home page Giter Site logo

sb-fbsde's Introduction

SB-FBSDE: Likelihood Training of Schrödinger Bridge using Forward-Backward SDEs Theory [ICLR 2022]

Official PyTorch implementation of the paper "Likelihood Training of Schrödinger Bridge using Forward-Backward SDEs Theory (SB-FBSDE)" which introduces a new class of deep generative models that generalizes score-based models to fully nonlinear forward and backward diffusions.

This repo is co-maintained by Guan-Horng Liu and Tianrong Chen. Contact us if you have any questions! If you find this library useful, please cite ⬇️

@inproceedings{chen2022likelihood,
  title={Likelihood Training of Schr{\"o}dinger Bridge using Forward-Backward SDEs Theory},
  author={Chen, Tianrong and Liu, Guan-Horng and Theodorou, Evangelos A},
  booktitle={International Conference on Learning Representations},
  year={2022}
}

Examples

p0 ⇆ pT (--problem-name) Results (blue/left: p0 ← pT, red/right: p0 → pT)
Mixture Gaussians ⇆ Gaussian (gmm) drawing
CheckerBoard ⇆ Gaussian (checkerboard) drawing
Spiral ⇆ Moon (moon-to-spiral) drawing
CIFAR-10 ⇆ Gaussian (cifar10)

drawing drawing

Installation

This code is developed with Python3. PyTorch >=1.7 (we recommend 1.8.1). First, install the dependencies with Anaconda and activate the environment sb-fbsde with

conda env create --file requirements.yaml python=3
conda activate sb-fbsde

Training

python main.py \
  --problem-name <PROBLEM_NAME> \
  --forward-net <FORWARD_NET> \
  --backward-net <BACKWARD_NET> \
  --num-FID-sample <NUM_FID_SAMPLE> \ # add this flag only for CIFAR-10
  --dir <DIR> \
  --log-tb 

To train an SB-FBSDE from scratch, run the above command, where

  • PROBLEM_NAME is the dataset. We support gmm (2D mixture of Gaussian), checkerboard (2D toy dataset), moon-to-spiral, mnist, celebA32, celebA64, cifar10.
  • FORWARD_NET & BACKWARD_NET are the deep networks for forward and backward drifts. We support Unet, nscnpp, and a toy network for 2D datasets.
  • NUM_FID_SAMPLE is the number of generated images used to evaluate FID locally. We recommend 10000 for training CIFAR-10. Note that this requires first downloading the FID statistics checkpoint.
  • DIR specifies where the results (e.g. snapshots during training) shall be stored.
  • log-tb enables logging with Tensorboard.

Additionally, use --load <LOAD> to restore previous checkpoint or pre-trained model. For training CIFAR-10 specifically, we support loading the pre-trained NCSN++ as the backward policy of the first SB training stage (this is because the first SB training stage can degenerate to denoising score matching under proper initialization; see more details in Appendix D of our paper).

Other configurations are detailed in options.py. The default configurations for each dataset are provided in the configs folder.

Evaluating the CIFAR-10 Checkpoint

To evaluate SB-FBSDE on CIFAR-10 (we achieve FID 3.01 and NLL 2.96), create a folder checkpoint then download the model checkpoint and FID statistics checkpoint either from Google Drive or through the following commands.

mkdir checkpoint && cd checkpoint

# FID stat checkpoint. This's needed whenever we
# need to compute FID during training or sampling.
gdown --id 1Tm_5nbUYKJiAtz2Rr_ARUY3KIFYxXQQD 

# SB-FBSDE model checkpoint for reproducing results in the paper.
gdown --id 1Kcy2IeecFK79yZDmnky36k4PR2yGpjyg 

After downloading the checkpoints, run the following commands for computing either NLL or FID. Set the batch size --samp-bs <BS> properly depending on your hardware.

# compute NLL
python main.py --problem-name cifar10 --forward-net Unet --backward-net ncsnpp --dir ICLR-2022-reproduce
  --load checkpoint/ciifar10_sbfbsde_stage_8.npz --compute-NLL --samp-bs <BS>
# compute FID
python main.py --problem-name cifar10 --forward-net Unet --backward-net ncsnpp --dir ICLR-2022-reproduce
  --load checkpoint/ciifar10_sbfbsde_stage_8.npz --compute-FID --samp-bs <BS> --num-FID-sample 50000 --use-corrector --snr 0.15

sb-fbsde's People

Contributors

ghliu avatar tianrongchen avatar

Stargazers

 avatar Chengzhong Wang avatar Griffin Seonho Lee avatar  avatar Byoungwoo Park avatar JUNGEE HONG avatar Thomas Boyer avatar Skirrey Sun avatar Shanlin Sun avatar Yunyi Shen avatar Radi Radev avatar Anthony Bao avatar  avatar Chris xUE avatar  avatar  avatar Charlie avatar Gabriel WATKINSON avatar Jérémie Stym-Popper avatar Brandon Amos avatar y6q9 avatar Jeff Sun avatar Shanchao Yang avatar  avatar  avatar Artlec avatar Siddharth Shrivastava avatar Clara avatar Hongteng avatar Jeongwhan Choi avatar MuhammadAnwar avatar Joa(quim) Gómez avatar Hannes Stärk avatar xiangze avatar Simon Dirmeier avatar  avatar genix avatar Kashif Rasul avatar Alexander Tong avatar Jianqi Zhang avatar Lin Min Htoo avatar Peter Whidden avatar Morgan Hough avatar  avatar Zhiwei ZHANG avatar  avatar Wei Deng avatar Ella avatar KiUngSong (송기웅) avatar chenwei avatar Jiarui Lu avatar  avatar  avatar  avatar JQ Liu avatar Dora Zhiyu Yang avatar Akash Patel avatar 爱可可-爱生活 avatar  avatar Min-Hung (Steve) Chen avatar Zhou avatar Shi-Yuan Wang avatar  avatar oswinso avatar  avatar  avatar Yen-Cheng Liu avatar Hao-Lun Hsu avatar

Watchers

 avatar Wei Deng avatar

sb-fbsde's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.