andrewgordonwilson / bayesgan

Tensorflow code for the Bayesian GAN (https://arxiv.org/abs/1705.09558) (NIPS 2017)
Other
1.02k stars 176 forks source link

Error when run bayesian_gan_hmc.py under tensorflow 1.3.0 #5

Closed githubjqh closed 6 years ago

githubjqh commented 6 years ago

Hi Andrew, I've just run bayesian_gan_hmc.py under tensorflow 1.3.0,here is the error: Traceback (most recent call last): File "/home/jqh/jiangqiuhua/eclipse/plugins/org.python.pydev_6.2.0.201711281614/pysrc/pydevd.py", line 1621, in <module> main() File "/home/jqh/jiangqiuhua/eclipse/plugins/org.python.pydev_6.2.0.201711281614/pysrc/pydevd.py", line 1615, in main globals = debugger.run(setup['file'], None, None, is_module) File "/home/jqh/jiangqiuhua/eclipse/plugins/org.python.pydev_6.2.0.201711281614/pysrc/pydevd.py", line 1022, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/home/jqh/jiangqiuhua/Tensorflow/bayesgan-master/bayesian_gan_hmc.py", line 442, in <module> b_dcgan(dataset, args) File "/home/jqh/jiangqiuhua/Tensorflow/bayesgan-master/bayesian_gan_hmc.py", line 141, in b_dcgan num_classes=dataset.num_classes if args.semi_supervised else 1) File "/home/jqh/jiangqiuhua/Tensorflow/bayesgan-master/bgan_models.py", line 357, in __init__ self.build_bgan_graph() File "/home/jqh/jiangqiuhua/Tensorflow/bayesgan-master/bgan_models.py", line 144, in build_bgan_graph self.generation["generators"].append(self.generator(self.z, gen_params)) File "/home/jqh/jiangqiuhua/Tensorflow/bayesgan-master/bgan_models.py", line 415, in generator h0 = tf.nn.relu(self.g_bn0(self.h0, reuse=reuse)) ValueError: Variable generator/g_bn0/moving_mean already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at: Can I run this under tensorflow 1.3.0?

LZChuan commented 6 years ago

I encountered the same problem. This link may give some help. http://www.tensorfly.cn/tfdoc/how_tos/variable_scope.html

ysaatchi commented 6 years ago

No it cannot, tf==1.0.0 for now.

Please use:

conda env create -f environment.yml -n bgan

To create the environment correctly.

drmeerkat commented 6 years ago

I spent some days onto this problem. Seems that batch norm in tf1.3 has some problem. That is to say, in a same name_scope given its name, it cannot automatically generate different name for the op like (name_scope/batch_norm_1 and name_scope/batch_norm_2) so you can modify the parameter "name" of batch norm which is fed into the tf.batch norm layer as its namescope. Then you can get something like name_scope_1/batch_norm name_scope_2/batch_norm. Basically it is manually setting different name scope to avoid this problem. But remember to set reuse bn in a same loop of G/D