GithubHelp home page GithubHelp logo

baiyancheng20 / generative-latent-optimization-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clvrai/generative-latent-optimization-tensorflow

0.0 2.0 0.0 20.58 MB

Tensorflow implementation of Generative Latent Optimization (GLO) proposed by Facebook AI Research

License: MIT License

Python 100.00%

generative-latent-optimization-tensorflow's Introduction

Generative Latent Optimization in Tensorflow

As part of the implementation series of Joseph Lim's group at USC, our motivation is to accelerate (or sometimes delay) research in the AI community by promoting open-source projects. To this end, we implement state-of-the-art research papers, and publicly share them with concise reports. Please visit our group github site for other projects.

This project is implemented by Shao-Hua Sun and the codes have been reviewed by Jiayuan Mao before being published.

Descriptions

This project is a Tensorflow implementation of Generative Latent Optimization (GLO) proposed in the paper Optimizing the Latent Space of Generative Networks. GLO is an exciting new generative model which enjoys many of the desirable properties of GANs including modeling data distributions, generating realistic samples, interpretable latent space, but more importantly, it doesn't suffer from unstable adversarial training dynamics.

GLO learns to map learnable latent vectors to samples in a target dataset by minimizing a reconstruction loss. During the traning phase, optimizing the parameters of the generator and tuning the corresponding latent vectors are alternatively performed. When converged, the model is able to generate novel samples given latent vectors sampled from the distribution. The illustration of the GLO framework is as follows.

The implemented model is trained and tested on three publicly available datasets: MNIST, SVHN, and CIFAR-10. Model's ability to recontruct samples, generate new samples, and interploate in a latent space are tested in this implementation.

Note that this implementation only follows the main idea of the original paper while differing a lot in implementation details such as model architectures, hyperparameters, applied optimizer, etc. Particularly, the updating procedure applied to latent vectors is mainly implemented based on my conjectures.

*This code is still being developed and subject to change.

Prerequisites

Usage

Datasets

Download datasets with specified settings. For examples:

$ python download.py --datasets MNIST --distribution PCA --dimension 10
$ python download.py --datasets SVHN --distribution Uniform --dimension 25
$ python download.py --datasets CIFAR10 --distribution Gaussian --dimension 35

Note that distribution indicates the initial distribution of the latent space and dimension specifies the dimension of each latent vector.

Train the models

Train models with downloaded datasets. For example:

$ python trainer.py --dataset MNIST --alpha 5 --dump_result --batch_size 32
$ python trainer.py --dataset SVHN --alpha 10 --lr_weight_decay
$ python trainer.py --dataset CIFAR10 --alpha 10 --learning_rate 1e-5

Note that alpha indicates the weight of updating latent vectors at each iteration.

Test the models

Test models with saved checkpoints:

$ python evaler.py --dataset MNIST --checkpoint ckpt_dir --prefix mnist --reconstruct --generate
$ python evaler.py --dataset SVHN --checkpoint ckpt_dir --prefix svhn  --interpolate
$ python evaler.py --dataset CIFAR10 --checkpoint ckpt_dir --prefix cifar 

There are three task options: reconstruction (--reconstruct), sample generation (--generate), and sample interpolation (--interpolate).

The ckpt_dir should be like: train_dir/default-MNIST_lr_0.0001-20170101-123456/model-1001

Train and test your own datasets:

  • Create a directory
$ mkdir datasets/YOUR_DATASET
  • Store your data as an h5py file datasets/YOUR_DATASET/data.hy and each data point contains
    • 'image': has shape [h, w, c], where c is the number of channels (grayscale images: 1, color images: 3)
    • 'code': represented as an vector sampled a distributionn
  • Maintain a list datasets/YOUR_DATASET/id.txt listing ids of all data points
  • Modify trainer.py.
  • Finally, test your trained models:
$ python evaler.py --dataset YOUR_DATASET

Results

SVHN

  • Reconstructed samples

  • Generated samples

  • Sample interpolation

  • Reconstructed process (first 73 epochs)

MNIST

  • Reconstructed samples

  • Generated samples

  • Sample interpolation

  • Reconstructed process (first 192 epochs)

CIFAR-10

  • Reconstructed samples

  • Generated samples

  • Sample interpolation

  • Reconstructed process (first 192 epochs)

Training details

SVHN

  • The reconstruction loss

MNIST

  • The reconstruction loss

CIFAR-10

  • The reconstruction loss

Related works

Author

Shao-Hua Sun / @shaohua0116 @ Joseph Lim's research lab @ USC

generative-latent-optimization-tensorflow's People

Contributors

shaohua0116 avatar vacancy avatar

Watchers

 avatar  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.