Giter VIP home page Giter VIP logo

ikostrikov / tensorflow-vae-gan-draw Goto Github PK

View Code? Open in Web Editor NEW
594.0 594.0 170.0 33 KB

A collection of generative methods implemented with TensorFlow (Deep Convolutional Generative Adversarial Networks (DCGAN), Variational Autoencoder (VAE) and DRAW: A Recurrent Neural Network For Image Generation).

License: Apache License 2.0

Python 100.00%
draw gan recurrent-neural-networks tensorflow vae

tensorflow-vae-gan-draw's People

Contributors

banus avatar ikostrikov2 avatar kchen92 avatar kmader avatar rubinovitz 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  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  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  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

tensorflow-vae-gan-draw's Issues

Loss

Shouldn't it be reduced_mean instead of reduced_sum when computing the vae and reconstruction loss?

AttributeError: 'module' object has no attribute 'global_variables_initializer'

Traceback (most recent call last):
File "main.py", line 43, in
model = VAE(FLAGS.hidden_size, FLAGS.batch_size, FLAGS.learning_rate)
File "/root/TensorFlow-VAE-GAN-DRAW/vae.py", line 51, in init
self.sess.run(tf.global_variables_initializer())
AttributeError: 'module' object has no attribute 'global_variables_initializer'

Generator runs only once per iteration

Hi,

Great work!

Usually in GAN, the generator is run twice to make sure that discriminator loss does not go to zero. And I noticed that you are not doing this in your implementation!

Thanks!

AttributeError: module 'mnist' has no attribute 'train_images'

Hello,
I got this error: AttributeError: module 'mnist' has no attribute 'train_images'
when I ran this code:
import mnist
import itertools
import numpy as np

def prepare_data(images, labels):
images = map(lambda a: a / 255.0, map(np.asarray, map(list, map(itertools.chain.from_iterable, images))))
return list(zip(images, labels))

train = prepare_data(mnist.train_images(), mnist.train_labels())
test = prepare_data(mnist.test_images(), mnist.test_labels())

Can you please help me?

TypeError: 'UnboundVariable' object does not support indexing

Hi, when I run the command 'python main-draw.py --working_directory /tmp/gan', I got the following error:

Traceback (most recent call last):
File "main-draw.py", line 190, in
gru_cell(num_units=FLAGS.rnn_size, state=pt.UnboundVariable('state')))
File "/home/amax/anaconda2/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 2011, in method
return func(input_layer, *args, **self.fill_kwargs(input_layer, kwargs))
File "/home/amax/anaconda2/lib/python2.7/site-packages/prettytensor/recurrent_networks.py", line 286, in gru_cell
state = state[0]
TypeError: 'UnboundVariable' object does not support indexing
The version of my tensorflow is 1.0
I use "pip install prettytensor" to install prettytensor 0.7.4
when I tried the example from the tutorial : https://github.com/google/prettytensor, it failed too
A = (pretty_tensor.template('x')
.lstm_cell(num_units=256, state=UnboundVariable('state'))

Thanks !

Prettytensor problem

When I try to run the code with prettytensor 0.7.3 and tensorflow 0.12.head, I get the error with no attribute tf.complex_abs, I assume that is because prettytensor doesn't support tensorflow 0.12.
However, when I try to run it with tensorflow 0.11.0rc1, I get the error no attribute 'GLOBAL_VARIABLES'. It seems like prettytensor requires tensorflow 0.12+.
Therefore I am stuck, are there any suggestions?

ProgressBar issue

I downloaded the package and upgraded TensorFlow to v0.9. However, the first test run did not work:

python main-vae.py -- working_directory /tmp/gan
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting MNIST/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting MNIST/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting MNIST/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting MNIST/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "main-vae.py", line 143, in <module>
    pbar = ProgressBar(max_value = FLAGS.updates_per_epoch, widgets=widgets)
TypeError: __init__() got an unexpected keyword argument 'max_value'

Apparently, something was changed in the ProgressBar package recently. Quick look at the examples revealed that maxval arg should be used rather than max_value.
Original:
pbar = ProgressBar(max_value = FLAGS.updates_per_epoch, widgets=widgets)
Modified:
pbar = ProgressBar(maxval = FLAGS.updates_per_epoch, widgets=widgets)
With this fix the package seems to work.

FailedPreconditionError

ENV(pip list)

tensorflow (0.12.0rc0)
prettytensor (0.6.2)

When I run this command

python main-vae.py

I encounter following problems. So I want to know what the env should be, or what should I do to fix the bug? Thanks for help.

WARNING:tensorflow:From main-vae.py:134 in .: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use tf.global_variables_initializer instead.
Traceback (most recent call last):
File "main-vae.py", line 148, in
_, loss_value = sess.run([train, loss], {input_tensor: x})
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 766, in run
run_metadata_ptr)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 964, in _run
feed_dict_string, options, run_metadata)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
target_list, options, run_metadata)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value model/conv2d/weights
[[Node: model/conv2d/weights/read = IdentityT=DT_FLOAT, _class=["loc:@model/conv2d/weights"], _device="/job:localhost/replica:0/task:0/cpu:0"]]

Caused by op u'model/conv2d/weights/read', defined at:
File "main-vae.py", line 120, in
output_tensor, mean, stddev = decoder(encoder(input_tensor))
File "main-vae.py", line 42, in encoder
conv2d(5, 32, stride=2).
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 1981, in method
result = func(non_seq_layer, *args, **kwargs)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/prettytensor/pretty_tensor_image_methods.py", line 159, in call
params = self.variable('weights', size, init, dt=dtype)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 1695, in variable
collections=variable_collections)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1024, in get_variable
custom_getter=custom_getter)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 850, in get_variable
custom_getter=custom_getter)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 346, in get_variable
validate_shape=validate_shape)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 331, in _true_getter
caching_device=caching_device, validate_shape=validate_shape)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 677, in _get_single_variable
expected_shape=shape)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 224, in init
expected_shape=expected_shape)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 370, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1424, in identity
result = _op_def_lib.apply_op("Identity", input=input, name=name)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/tangluming/niuge/ENV/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1128, in init
self._traceback = _extract_stack()

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value model/conv2d/weights
[[Node: model/conv2d/weights/read = IdentityT=DT_FLOAT, _class=["loc:@model/conv2d/weights"], _device="/job:localhost/replica:0/task:0/cpu:0"]]

VAE loss

Hi,

Awesome code!

A minor issue. Following paper https://arxiv.org/pdf/1312.6114.pdf, equation 10, it seems line 62 of vae.py

tf.reduce_sum(0.5 * (tf.square(mean) + tf.square(stddev) - 2.0 * tf.log(stddev + epsilon) - 1.0))

should be

tf.reduce_sum(0.5 * (tf.square(mean) + tf.square(stddev) - tf.log(stddev + epsilon) - 1.0))

AttributeError: 'module' object has no attribute '_VariableScope'

envy@ub1404:/os_pri/github/TensorFlow-VAE-GAN-DRAW$ python main-vae.py --working_directory .
Extracting ./MNIST/train-images-idx3-ubyte.gz
Extracting ./MNIST/train-labels-idx1-ubyte.gz
Extracting ./MNIST/t10k-images-idx3-ubyte.gz
Extracting ./MNIST/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
File "main-vae.py", line 120, in
output_tensor, mean, stddev = decoder(encoder(input_tensor))
File "main-vae.py", line 41, in encoder
reshape([FLAGS.batch_size, 28, 28, 1]).
File "/home/envy/.local/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 1816, in method
with _method_scope(input_layer, scope_name) as (scope, _):
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/home/envy/.local/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 1628, in _method_scope
scopes.var_and_name_scope((name, None)) as (scope, var_scope):
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "/home/envy/.local/lib/python2.7/site-packages/prettytensor/scopes.py", line 57, in var_and_name_scope
vs_key[0] = variable_scope._VariableScope(
AttributeError: 'module' object has no attribute '_VariableScope'
envy@ub1404:
/os_pri/github/TensorFlow-VAE-GAN-DRAW$

Is elu better than lrelu?

I found that you used elu as the activation function for gan, but on the DCGAN paper they suggest us to use lrelu for the discriminator, relu for encoder and decoder. Also elu is pretty new. I wonder if there is some logic behind your choice.

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.