shekkizh / WassersteinGAN.tensorflow

Tensorflow implementation of Wasserstein GAN - arxiv: https://arxiv.org/abs/1701.07875
MIT License
416 stars 130 forks source link

Tensorflow v0.12.1 get placeboarder error for train_phase #2

Closed hqqxyy closed 7 years ago

hqqxyy commented 7 years ago

It's really a great work for the implementation of WGAN. This code is very clear, readable and well-written. However, when I try to run the code under TF v0.12.1, I got an error

Traceback (most recent call last): File "main.py", line 52, in tf.app.run() File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run sys.exit(main(sys.argv[:1] + flags_passthrough)) File "main.py", line 43, in main model.initialize_network(FLAGS.logs_dir) File "/home/qiqi/code/wgan/WassersteinGAN.tensorflow/models/GAN_models.py", line 227, in initialize_network self.sess.run(init) File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 766, in run run_metadata_ptr) File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 964, in _run feed_dict_string, options, run_metadata) File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run target_list, options, run_metadata) File "/home/qiqi/anaconda2/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.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype bool [[Node: Placeholder = Placeholder[dtype=DT_BOOL, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

Caused by op u'Placeholder', defined at: File "main.py", line 52, in tf.app.run() File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run sys.exit(main(sys.argv[:1] + flags_passthrough)) File "main.py", line 41, in main FLAGS.optimizer_param) File "/home/qiqi/code/wgan/WassersteinGAN.tensorflow/models/GAN_models.py", line 173, in create_network self._setup_placeholder() File "/home/qiqi/code/wgan/WassersteinGAN.tensorflow/models/GAN_models.py", line 149, in _setup_placeholder self.train_phase = tf.placeholder(tf.bool) File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1512, in placeholder name=name) File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2043, in _placeholder name=name) File "/home/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op op_def=op_def) File "/home/qiqi/anaconda2/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/qiqi/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1128, in init self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype bool [[Node: Placeholder = Placeholder[dtype=DT_BOOL, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]]

I try to fix it. But I don't have an idea where I should get started.

I test

import tensorflow as tf
a = tf.placeholder(tf.bool)
b = tf.constant(2)
c = tf.constant(3)
d = tf.cond(a, lambda: tf.add(b, c), lambda: tf.mul(b, c))
init  = tf.global_variables_initializer()
tf.Session().run(init)
tf.Session().run(d, {a: True})

It runs correctly.

So, would you mind giving a hint where should I start to debug?

Thank you very much.

shekkizh commented 7 years ago

Hi @hqqxyy, I haven't played around with tf0.12.1 much. There is a similar question in stackoverflow

The solution as suggested in stackoverflow is basically to feed values for bool tensor while initializing. In this case, maybe try below line for initializing sess.run(tf.global_variables_initializer(),{self.train_phase:True})

Let me know if that works.

hqqxyy commented 7 years ago

@shekkizh It works ! Thank you very much!