Giter Club home page Giter Club logo

mintnet's Introduction

MintNet: Building Invertible Neural Networks with Masked Convolutions

This repository contains the PyTorch implementation of our paper: MintNet: Building Invertible Neural Networks with Masked Convolutions, NeurIPS 2019 . We propose a new way of constructing invertible neural networks by combining simple building blocks with a novel set of composition rules. This leads to a rich set of invertible architectures, including those similar to ResNets. Inversion is achieved with a locally convergent iterative procedure that is parallelizable and very fast in practice. Additionally, the determinant of the Jacobian can be computed analytically and efficiently, enabling their generative use as flow models.

Dependencies

The following are packages needed for running this repo.

  • PyTorch==1.1.0
  • tqdm
  • tensorboardX
  • Scipy
  • PyYAML
  • Numba

Running the experiments

python main.py --runner [runner name] --config [config file] --doc [experiment folder name]

Here runner name is one of the following:

  • DensityEstimationRunner. Experiments on MintNet density estimation.
  • ClassificationRunner. Experiments on MintNet classification.

config file is the directory of some YAML file in configs/, and experiment folder name is the folder names in run/.

For example, if you want to train MintNet density estimation model on MNIST, just run

python main.py --runner DensityEstimationRunner --config mnist_density_config.yml

Checkpoints

Checkpoints for both density estimation and classification can be downloaded from https://drive.google.com/file/d/12kGMMg0ivJI5y32hRouhZuddr9cJxfiR/view?usp=sharing

Unzip it to <root folder>/run.

mintnet's People

Contributors

chenlin9 avatar yang-song avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mintnet's Issues

Why the determinant of the jacobian is 0 ?

Hi @yang-song

I use the following code to test the BasicBlock, but I found the determinant is always 0. Is this normal? I am looking forward to your reply.

basic_model = BasicBlock(
        input_dim=3,
        latent_dim=32,
        kernel1=3,
        kernel2=3,
        kernel3=3,
        type='A',
        config=config,
        shape=[3, 32, 32],
        init_zero=False,
    )
x = torch.randn(1, 3, 32, 32)
log_det = torch.zeros(1)
out, log_det = basic_model([x, log_det])
print(log_det)

Out: tensor([0.], grad_fn=<AddBackward0>)

Same model for classification as well as generating samples

Hey, thank you for sharing the code. It's great!
I had one query. I have trained a Mintnet model for classification on CIFAR10. Can I use this same model for generating new samples i.e as a generative model (with some code modifications, of course)? If yes, can you suggest what part of the code needs to be changed?
As far as I understood, currently, density estimation and classification experiments are run independently, but I want to make changes to achieve the above use-case.
Thanks in advance!

Verification of invertibility

Hi @yang-song,
Thanks for releasing the code, I really enjoy your paper and would like to use the invertibility in our work.
However, I cannot find the inverse functions in the MintNet class or Mint Block in your code.
Also, how can we reproduce Fig.4a (verification of invertibility)?
Thanks

Comment on Cifar10 Classification and Pretrained Models

Hello! I have really enjoyed reading your paper and want to do some experiments with the invertible network on Cifar-10. However, I think there are some small mistakes with the CIFAR-10 config file, namely that it refers to MNIST and has the wrong image size (28 instead of 32). After rectifying this, I get another error, namely

File "/home/kyle/mintnet/models/cnn_classification.py", line 122, in forward
    center2 = center2.permute(0, 2, 1, 3, 4, 5).contiguous().view_as(self.weight2)
RuntimeError: shape '[16, 16, 1, 1]' is invalid for input of size 2304

I'm guessing some other parameter in this config file is not correct, but I couldn't determine which one from the paper. Would you be able to help me figure it out?

Additionally, would you happen to have checkpoints for the trained CIFAR10 model lying around? At least for now, I don't actually need to train a model myself, I just want to use a trained one.

Thanks in advance!

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.