GithubHelp home page GithubHelp logo

tariqahassan / conditional-pixelcnn-decoder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anantzoid/conditional-pixelcnn-decoder

0.0 1.0 0.0 2.57 MB

Tensorflow implementation of Gated Conditional Pixel Convolutional Neural Network

Python 100.00%

conditional-pixelcnn-decoder's Introduction

Image Generation with Gated PixelCNN Decoders

This is a Tensorflow implementation of Conditional Image Generation with PixelCNN Decoders which introduces the Gated PixelCNN model based on PixelCNN architecture originally mentioned in Pixel Recurrent Neural Networks. The model can be conditioned on latent representation of labels or images to generate images accordingly. Images can also be modelled unconditionally. It can also act as a powerful decoder and can replace deconvolution (transposed convolution) in Autoencoders and GANs. A detailed summary of the paper can be found here.

These are some conditioned samples generated by the authors of the paper:

Paper Sample

Architecture

This is the architecture for Gated PixelCNN used in the model:

Gated PCNN

The gating accounts for remembering the context and model more complex interactions, like in LSTM. The network stack on the left is the Vertical stack that takes care of blind spots that occure while convolution due to the masking layer (Refer the Pixel RNN paper to know more about masking). Use of residual connection significantly improves the model performance.

Usage

This implementation consists of the following models based on the Gated PixelCNN architecture:

  • Unconditional image generation:

    python main.py
    

    Sample generated by training MNIST dataset after 70 epochs with a cross-entropy loss of 0.104610:

    Unconditional image

  • Conditional image generation based on class labels:

    python main.py --model=conditional
    

    As mentioned in the paper, conditionally generated images are more visually appealing though the loss difference is almost same. It has a loss of 0.102719 after 40 epochs:

    Conditional image

  • Autoencoder with PixelCNN decoder:

    python main.py --model=autoencoder
    

    The encoder part of the autoencoder has the original architecture as mentioned in Stacked Convolutional Auto-Encoders for Hierarchical Feature Extraction. The representation is encoded into 10d tensor. The image generated after 10 epochs with a loss of 0.115306:

    AE image

To only generate images append the --epochs=0 flag after the command.

To train the any model on CIFAR-10 dataset, add the --data=cifar flag.

Refer main.py for other available flags for hyperparameter tuning.

Training Details

The system was trained on a single AWS p2.xlarge spot instance. The implementation was only done on MNIST dataset. Generation of samples based on CIFAR-10 images took the authors 32 GPUs trained for 60 hours.

To visualize the graph and loss during training, run:

tensorboard --logdir=logs

Loss minimization for the autoencoder model:

Loss

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.