Coder Social home page Coder Social logo

edshkim98 / heatdiffusion Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aaltoml/generative-inverse-heat-dissipation

0.0 0.0 0.0 38.61 MB

Code release for the paper Generative Modeling With Inverse Heat Dissipation

Home Page: https://aaltoml.github.io/generative-inverse-heat-dissipation/

License: MIT License

Python 100.00%

heatdiffusion's Introduction

Generative Modelling With Inverse Heat Dissipation

This repository is the official implementation of the methods in the publication:

  • Severi Rissanen, Markus Heinonen, and Arno Solin (2023). Generative Modelling With Inverse Heat Dissipation. In International Conference on Learning Representations (ICLR). [arXiv] [project page]

Arrangement of code

The "configs" folder contains the configuration details on different experiments and the "data" folder contains the data. MNIST and CIFAR-10 should run as-is with automatic torchvision data loading, but the other experiments require downloading the data to the corresponding data/ folders. The "model_code" contains the U-Net definition and utilities for working with the proposed inverse heat dissipation model. "scripts" contains additional code, for i/o, data loading, loss calculation and sampling. "runs" is where the results get saved at.

Used Python packages

The file "requirements.txt" contains the Python packages necessary to run the code, and they can be installed by running

pip install -r requirements.txt

If you have issues with installing the mpi4py through pip, you can also install it using conda with conda install -c conda-forge mpi4py.

Training

You can get started by running an MNIST training script with

python train.py --config configs/mnist/default_mnist_configs.py --workdir runs/mnist/default

This creates a folder "runs/mnist/default", which contains the folder "checkpoint-meta", where the newest checkpoint is saved periodically. "samples" folder contains samples saved during training. You can change the frequency of checkpointing and sampling with the command line flags "training.snapshot_freq_for_preemption=?" and "config.training.sampling_freq=?".

Sampling

Once you have at least one checkpoint, you can do sampling with "sample.py", with different configurations:

Random samples

Random samples:

python sample.py --config configs/mnist/default_mnist_configs.py
                 --workdir runs/mnist/default --checkpoint 0 --batch_size=9

Share the initial state

Samples where the prior state u_K is fixed, but the sampling noise is different:

python sample.py --config configs/mnist/default_mnist_configs.py
                 --workdir runs/mnist/default --checkpoint 0 --batch_size=9
                 --same_init

Share the noise

Samples where the prior state u_K changes, but the sampling noises are shared (results in similar overall image characteristics, but different average colours if the maximum blur is large enough):

python sample.py --config configs/mnist/default_mnist_configs.py
                 --workdir runs/mnist/default --checkpoint 0 --batch_size=9
                 --share_noise

Interpolation

Produces an interpolation between two random points generated by the model.

python sample.py --config configs/mnist/default_mnist_configs.py
                 --workdir runs/mnist/default --checkpoint 0 --interpolate --num_points=20

Evaluation

The script "evaluation.py" contains code for evaluating the model with FID-scores and NLL (ELBO) values. For example, if you have a trained cifar-10 model trained with configs/cifar10/default_cifar10_configs.py and the result is in the folder runs/cifar10/default/checkpoints-meta, you can run the following (checkpoint=0 refers to the last checkpoint, other checkpoints in runs/cifar10/default/checkpoints are numbered as 1,2,3,...):

FID scores

This assumes that you have clean-fid installed.

python evaluate.py --config configs/cifar10/default_cifar10_configs.py
            --workdir runs/cifar10/default --checkpoint 0
            --dataset_name=cifar10
            --experiment_name=experiment1 --param_name=default --mode=fid
            --delta=0.013 --dataset_name_cleanfid=cifar10
            --dataset_split=train --batch_size=128 --num_gen=50000

NLL values

The result contains a breakdown of the different terms in the NLL.

python evaluate.py --config configs/cifar10/default_cifar10_configs.py
            --workdir runs/cifar10/default --checkpoint 0
            --dataset_name=cifar10
            --experiment_name=experiment1 --param_name=default --mode=elbo
            --delta=0.013

Result folder

The results will be saved in the folder runs/cifar10/evaluation_results/experiment1/ in log files, where you can read them out. The idea in general is that experiment_name is an upper-level name for a suite of experiments that you might want to have (e.g., FID w.r.t. different delta), and param_name is the name of the calculated value within that experiment (e.g., "delta0.013" or "delta0.012").

Citation

If you use the code in this repository for your research, please cite the paper as follows:

@inproceedings{rissanen2023generative,
  title={Generative modelling with inverse heat dissipation},
  author={Severi Rissanen and Markus Heinonen and Arno Solin},
  booktitle={International Conference on Learning Representations (ICLR)},
  year={2023}
}

License

This software is provided under the MIT license.

heatdiffusion's People

Contributors

severi-rissanen avatar

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.