Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encounter ValueError when I "python dcgan.py" #4

Closed
duduheihei opened this issue Aug 8, 2017 · 2 comments
Closed

encounter ValueError when I "python dcgan.py" #4

duduheihei opened this issue Aug 8, 2017 · 2 comments

Comments

@duduheihei
Copy link

duduheihei commented Aug 8, 2017

ValueError: Variable G_conv/Conv/weights does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

I wonder if I am the only one who meet this problem and I have been confused for days. I hope I can get some help.

here is the information
Traceback (most recent call last):
File "dcgan.py", line 107, in
dcgan = DCGAN(generator, discriminator, data)
File "dcgan.py", line 34, in init
self.D_real, _ = self.discriminator(self.X)
File "/home/baiqiujian/github/GAN-master/nets.py", line 146, in call
stride=2, activation_fn=lrelu)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args
return func(*args, **current_args)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 947, in convolution
outputs = layer.apply(inputs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 492, in apply
return self.call(inputs, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 434, in call
self.build(input_shapes[0])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/convolutional.py", line 137, in build
dtype=self.dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.py", line 374, in add_variable
trainable=trainable and self.trainable)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 1065, 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 962, 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 360, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1370, in layer_variable_getter
return _model_variable_getter(getter, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1362, in _model_variable_getter
custom_getter=getter, use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args
return func(*args, **current_args)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/variables.py", line 261, in model_variable
use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args
return func(*args, **current_args)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/variables.py", line 216, in variable
use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 682, in _get_single_variable
"VarScope?" % name)
ValueError: Variable G_conv/Conv/weights does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

@yfeng95
Copy link
Owner

yfeng95 commented Aug 15, 2017

So sorry for my late reply, for I saw your issue just now (I haven't used computer over the last two weeks)

About the error, you are right, reuse=False can correct this.

And it's all by my carelessness, I forgot to delete the file net.py in the root folder, as the file utils/net.py is the right one. So the executed file dcgan.py just run the wrong code in ./net.py instead of right code in ./utils/net.py.

Anyway, I've just fixed this. Thank you very much for your reporting. :-D

@duduheihei
Copy link
Author

Thank you very much for solving this problem and providing such a good learning material for GAN and tf.

@yfeng95 yfeng95 closed this as completed Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants