GithubHelp home page GithubHelp logo

tf-dcgan's Introduction

tf-dcgan

Introduction

This repository contains a TensorFlow implementation of Deep Convolutional Generative Adversarial Networks, with some modifications. Specifically, this implementation makes the following changes:

  • An extra 3x3 convolutional layer is added to the end of the generator network. The body of the discriminator network is left unchanged.
  • Batch normalization is applied to the input of each convolutional layer instead of after.
  • Global average pooling is utilized in the discriminator instead of a densely connected layer.

The discriminator uses ReLU non-linearities instead of LReLU.

These changes were made for experimental purposes, and seem to improve both stability and visual results datasets I'm interested in. They may or may not work better for others. For a DCGAN implementation with the models used in the paper, switch to the original branch.

Requirements

  • Python (2.7 or 3.5)
  • TensorFlow >= 0.8

Usage

To train your own model, clone this repository and run:

python dcgan.py -t <train_dir> -o <output_dir>

This will snapshot weights as well as intermediate generations to the directory specified by <output_dir>. To generate samples from a trained model, simply omit the -t flag:

python dcgan.py -o <output_directory>

For more options, run:

python dcgan.py -h

Samples

All of the images below are artificial creations from the generator network, i.e. the "celebrities" shown below are not actual people.

Celebrities - 64x64 generations on CelebA (resized such that the smaller dimension is 112, followed by a center crop):

Small, canonical images - 64x64 generations on CIFAR-10:

More sample generations on some custom datasets will follow. I'm also planning on training larger outputs (128x128) on larger datasets such as YFCC100M.

Pre-trained Models

Pre-trained models "coming soon" โ„ข.

tf-dcgan's People

Contributors

fzliu avatar

Stargazers

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

Watchers

 avatar

tf-dcgan's Issues

scope issue

Traceback (most recent call last):
File "dcgan.py", line 325, in
main(args)
File "dcgan.py", line 316, in main
args.image_size, args.scale_size, args.restore, paths)
File "dcgan.py", line 199, in train_dcgan
D_real = discriminator(real, is_train)
File "/home/chandra/ankit/ganOnCifar/tf-dcgan/models.py", line 172, in discriminator
conv2 = tf.nn.relu(conv2d("d_conv2", conv1, [5, 5, 128, 256], STRIDE_2, is_train=is_train))
File "/home/chandra/ankit/ganOnCifar/tf-dcgan/models.py", line 62, in conv2d
bn = _bn(bottom, is_train) if with_bn else bottom
File "/home/chandra/ankit/ganOnCifar/tf-dcgan/models.py", line 47, in _bn
(mean, variance) = tf.cond(is_train, train_op, test_op)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 1741, in cond
orig_res, res_t = context_t.BuildCondBranch(fn1)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 1642, in BuildCondBranch
r = fn()
File "/home/chandra/ankit/ganOnCifar/tf-dcgan/models.py", line 38, in train_op
ema_op = ema.apply([mu, var])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/moving_averages.py", line 375, in apply
colocate_with_primary=(var.op.type in ["Variable", "VariableV2"]))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 174, in create_zeros_slot
colocate_with_primary=colocate_with_primary)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 149, in create_slot_with_initializer
dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/slot_creator.py", line 66, in _create_slot_var
validate_shape=validate_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 1049, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 948, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 356, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 341, in _true_getter
use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 671, in _get_single_variable
"VarScope?" % name)
ValueError: Variable d_conv2/d_conv2_1/moments/normalize/mean/ExponentialMovingAverage/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

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.