Code to reproduce results from the paper "AmbientGAN: Generative models from lossy measurements"

Overview

AmbientGAN: Generative models from lossy measurements

This repository provides code to reproduce results from the paper AmbientGAN: Generative models from lossy measurements.

The training setup is as in the following diagram:

Here are a few example results:

Measured Baseline AmbientGAN (ours)

Few more samples from AmbientGAN models trained with 1-D projections:

Pad-Rotate-Project Pad-Rotate-Project-theta

The rest of the README describes how to reproduce the results.

Requirements

  • Python 2.7
  • Tensorflow >= 1.4.0
  • matplotlib
  • scipy
  • numpy
  • cvxpy
  • scikit-learn
  • tqdm
  • opencv-python
  • pandas

For pip installation, use $ pip install -r requirements.txt

Get the data

  • MNIST data is automatically downloaded
  • Get the celebA dataset here and put the jpeg files in ./data/celebA/
  • Get the CIFAR-10 python data from here and put it in ./data/cifar10/cifar-10-batches-py/*

Get inference models

We need inference models for computing the inception score.

  • For MNIST, you can train your own by

    cd ./src/mnist/inf
    python train.py
    

    [TODO]: Provide a pretrained model.

  • Inception model for use with CIFAR-10 is automatically downloaded.

Create experiment scripts

Run ./create_scripts/create_scripts.sh

This will create scripts for all the experiments in the paper.

[Optional] If you want to run only a subset of experiments you can define the grid in ./create_scripts/DATASET_NAME/grid_*.sh or if you wish to tweak a lot of parameters, you can change ./create_scripts/DATASET_NAME/base_script.sh. Then run ./create_scripts/create_scripts.sh as above to create the corresponding scripts (remember to remove any previous files from ./scripts/)

Run experiments

We provide scripts to train on multiple GPUs in parallel. For example, if you wish to use 4 GPUs, you can run: ./run_scripts/run_sequentially_parallel.sh "0 1 2 3"

This will start 4 GNU screens. Each program within the screen will attempt to acquire and run experiments from ./scripts/, one at a time. Each experiment run will save samples, checkpoints, etc. to ./results/.

See results as you train

Samples

You can see samples for each experiment in ./results/samples/EXPT_DIR/

EXPT_DIR is defined based on the hyperparameters of the experiment. See ./src/commons/dir_def.py to see how this is done.

Quantitative plots

Run

python src/aggregator_mnist.py
python src/aggregator_cifar.py

This will create pickle files in ./results/ with the relevant data in a Pandas dataframe.

Now use the ipython notebooks ./plotting_mnist.ipynb and ./plotting_cifar.ipynb to get the relevant plots. The generated plots are also saved to ./results/plots/ (make sure this directory exists)

You might also like...
PyTorch Implementation of Fully Convolutional Networks. (Training code to reproduce the original result is available.)
PyTorch Implementation of Fully Convolutional Networks. (Training code to reproduce the original result is available.)

pytorch-fcn PyTorch implementation of Fully Convolutional Networks. Requirements pytorch = 0.2.0 torchvision = 0.1.8 fcn = 6.1.5 Pillow scipy tqdm

Source code and notebooks to reproduce experiments and benchmarks on Bias Faces in the Wild (BFW).
Source code and notebooks to reproduce experiments and benchmarks on Bias Faces in the Wild (BFW).

Face Recognition: Too Bias, or Not Too Bias? Robinson, Joseph P., Gennady Livitz, Yann Henon, Can Qin, Yun Fu, and Samson Timoner. "Face recognition:

This code reproduces the results of the paper, "Measuring Data Leakage in Machine-Learning Models with Fisher Information"

Fisher Information Loss This repository contains code that can be used to reproduce the experimental results presented in the paper: Awni Hannun, Chua

This repository contains the source code and data for reproducing results of Deep Continuous Clustering paper
This repository contains the source code and data for reproducing results of Deep Continuous Clustering paper

Deep Continuous Clustering Introduction This is a Pytorch implementation of the DCC algorithms presented in the following paper (paper): Sohil Atul Sh

Code for sound field predictions in domains with impedance boundaries. Used for generating results from the paper

Code for sound field predictions in domains with impedance boundaries. Used for generating results from the paper

This repository contains the code and models necessary to replicate the results of paper:  How to Robustify Black-Box ML Models? A Zeroth-Order Optimization Perspective
This repository contains the code and models necessary to replicate the results of paper: How to Robustify Black-Box ML Models? A Zeroth-Order Optimization Perspective

Black-Box-Defense This repository contains the code and models necessary to replicate the results of our recent paper: How to Robustify Black-Box ML M

This repository contains the code and models necessary to replicate the results of paper:  How to Robustify Black-Box ML Models? A Zeroth-Order Optimization Perspective
This repository contains the code and models necessary to replicate the results of paper: How to Robustify Black-Box ML Models? A Zeroth-Order Optimization Perspective

Black-Box-Defense This repository contains the code and models necessary to replicate the results of our recent paper: How to Robustify Black-Box ML M

Official codebase for "B-Pref: Benchmarking Preference-BasedReinforcement Learning" contains scripts to reproduce experiments.

B-Pref Official codebase for B-Pref: Benchmarking Preference-BasedReinforcement Learning contains scripts to reproduce experiments. Install conda env

Reproduce ResNet-v2(Identity Mappings in Deep Residual Networks) with MXNet
Reproduce ResNet-v2(Identity Mappings in Deep Residual Networks) with MXNet

Reproduce ResNet-v2 using MXNet Requirements Install MXNet on a machine with CUDA GPU, and it's better also installed with cuDNN v5 Please fix the ran

Comments
  • MEASUREMENT MODELS to be differentiable?

    MEASUREMENT MODELS to be differentiable?

    Hi, In your paper, It's said "We additionally require f(θ)to be differentiable with respect to its inputs for all θ,I don't what its mean.

    It is necessary to derivate D(fθ(G(Z))) by myself? In my problem, I want to add a rician noise to Generative image? I don't know how to add this derivate process to the train.

    I review your code, I don't see how to deal with this derivate process, seveal measurement models are quite complex, is it necessary to derivate explicitly?

    Another question, if I can obtain the noise data in experiment as the lossy measurements, is it reasonable to add the noise to Generative image just as the role of f(θ), but the derivate compute may be complex.

    opened by duancaohui 1
  • Troubles trying to reproduce the results

    Troubles trying to reproduce the results

    Hi, My name is Alejandro Barredo Arrieta and I am trying reproduce your implentation for a research study I am conducting. I am trying to run your steps for the cifar dataset and found a couple of problems. I do not know if are only problems on my side or are actually problems on the implementation:

    1. inception_score.py - line 112 - logits = tf.matmul(tf.squeeze(pool3), w) throws the error - > tensor of rank 2 needed for matmul and [, xxx] was given. So I changed it to: logits = tf.matmul(tf.reshape(tf.squeeze(pool3), [1, -1]), w)

    2. for the second error, I do not know what is causing it, so I hope you can help. Running the generated scripts it throws: Traceback (most recent call last): File "src/cifar/gan_cifar_resnet.py", line 260, in <module> AMB_HPARAMS = amb_setup() File "src/cifar/gan_cifar_resnet.py", line 247, in amb_setup hparams = amb_hparams_def.get_hparams(args) File "/home/xai/Documentos/AmbientGAN/src/cifar/amb_hparams_def.py", line 7, in get_hparams hparams = tf.contrib.training.HParams( File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/python/util/lazy_loader.py", line 53, in __getattr__ module = self._load() File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/python/util/lazy_loader.py", line 42, in _load module = importlib.import_module(self.__name__) File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/contrib/__init__.py", line 47, in <module> from tensorflow.contrib import image File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/contrib/image/__init__.py", line 70, in <module> from tensorflow.contrib.image.python.ops.single_image_random_dot_stereograms import single_image_random_dot_stereograms File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/contrib/image/python/ops/single_image_random_dot_stereograms.py", line 27, in <module> "_single_image_random_dot_stereograms.so")) File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/contrib/util/loader.py", line 56, in load_op_library ret = load_library.load_op_library(path) File "/home/xai/anaconda3/envs/AmbientGAN/lib/python2.7/site-packages/tensorflow/python/framework/load_library.py", line 73, in load_op_library exec(wrappers, module.__dict__) File "<string>", line 27 def single_image_random_dot_stereograms(depth_values, hidden_surface_removal=True, convergence_dots_size=8, dots_per_inch=72, eye_separation=2,5, mu=0,333299994, normalize=True, normalize_max=-100, normalize_min=100, border_level=0, number_colors=256, output_image_shape=[1024, 768, 1], output_data_window=[1022, 757], name=None): Thanks in advance for posting your code.

    opened by sakur33 0
Owner
Ashish Bora
Ashish Bora
Code to reproduce the results for Statistically Robust Neural Network Classification, published in UAI 2021

Code to reproduce the results for Statistically Robust Neural Network Classification, published in UAI 2021

null 1 Jun 2, 2022
In this repo we reproduce and extend results of Learning in High Dimension Always Amounts to Extrapolation by Balestriero et al. 2021

In this repo we reproduce and extend results of Learning in High Dimension Always Amounts to Extrapolation by Balestriero et al. 2021. Balestriero et

Sean M. Hendryx 1 Jan 27, 2022
The LaTeX and Python code for generating the paper, experiments' results and visualizations reported in each paper is available (whenever possible) in the paper's directory

This repository contains the software implementation of most algorithms used or developed in my research. The LaTeX and Python code for generating the

João Fonseca 3 Jan 3, 2023
Code to reproduce the experiments in the paper "Transformer Based Multi-Source Domain Adaptation" (EMNLP 2020)

Transformer Based Multi-Source Domain Adaptation Dustin Wright and Isabelle Augenstein To appear in EMNLP 2020. Read the preprint: https://arxiv.org/a

CopeNLU 36 Dec 5, 2022
Code reproduce for paper "Vehicle Re-identification with Viewpoint-aware Metric Learning"

VANET Code reproduce for paper "Vehicle Re-identification with Viewpoint-aware Metric Learning" Introduction This is the implementation of article VAN

EMDATA-AILAB 23 Dec 26, 2022
Code to reproduce experiments in the paper "Explainability Requires Interactivity".

Explainability Requires Interactivity This repository contains the code to train all custom models used in the paper Explainability Requires Interacti

Digital Health & Machine Learning 5 Apr 7, 2022
Code to reproduce the experiments from our NeurIPS 2021 paper " The Limitations of Large Width in Neural Networks: A Deep Gaussian Process Perspective"

Code To run: python runner.py new --save <SAVE_NAME> --data <PATH_TO_DATA_DIR> --dataset <DATASET> --model <model_name> [options] --n 1000 - train - t

Geoff Pleiss 5 Dec 12, 2022
The codes reproduce the figures and statistics in the paper, "Controlling for multiple covariates," by Mark Tygert.

The accompanying codes reproduce all figures and statistics presented in "Controlling for multiple covariates" by Mark Tygert. This repository also pr

Meta Research 1 Dec 2, 2021
Applications using the GTN library and code to reproduce experiments in "Differentiable Weighted Finite-State Transducers"

gtn_applications An applications library using GTN. Current examples include: Offline handwriting recognition Automatic speech recognition Installing

Facebook Research 68 Dec 29, 2022
This repo will contain code to reproduce and build upon understanding transfer learning

What is being transferred in transfer learning? This repo contains the code for the following paper: Behnam Neyshabur*, Hanie Sedghi*, Chiyuan Zhang*.

null 4 Jun 16, 2021