adeshpande3 / generative-adversarial-networks Goto Github PK
View Code? Open in Web Editor NEWTutorial on GANs
Tutorial on GANs
Hi,
I am getting an error right after "Let's now see what a sample image looks like after training", at
sample_image = generator(z_placeholder, 1, z_dimensions)
I am using tensorflow 1.2.1 .
The whole dump is
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-29-c37b1698fba8> in <module>()
----> 1 sample_image = generator(z_placeholder, 1, z_dimensions)
2 z_batch = np.random.normal(-1, 1, size=[1, z_dimensions])
3 temp = (sess.run(sample_image, feed_dict={z_placeholder: z_batch}))
4 my_i = temp.squeeze()
5 plt.imshow(my_i, cmap='gray_r')
<ipython-input-15-b5a26c2e15ce> in generator(z, batch_size, z_dim, reuse)
16 output1_shape = [batch_size, s8, s8, g_dim*4]
17 W_conv1 = tf.get_variable('g_wconv1', [5, 5, output1_shape[-1], int(h0.get_shape()[-1])],
---> 18 initializer=tf.truncated_normal_initializer(stddev=0.1))
19 b_conv1 = tf.get_variable('g_bconv1', [output1_shape[-1]], initializer=tf.constant_initializer(.1))
20 H_conv1 = tf.nn.conv2d_transpose(h0, W_conv1, output_shape=output1_shape, strides=[1, 2, 2, 1], padding='SAME')
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, use_resource, custom_getter)
1063 collections=collections, caching_device=caching_device,
1064 partitioner=partitioner, validate_shape=validate_shape,
-> 1065 use_resource=use_resource, custom_getter=custom_getter)
1066 get_variable_or_local_docstring = (
1067 """%s
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, var_store, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, use_resource, custom_getter)
960 collections=collections, caching_device=caching_device,
961 partitioner=partitioner, validate_shape=validate_shape,
--> 962 use_resource=use_resource, custom_getter=custom_getter)
963
964 def _get_partitioned_variable(self,
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, use_resource, custom_getter)
365 reuse=reuse, trainable=trainable, collections=collections,
366 caching_device=caching_device, partitioner=partitioner,
--> 367 validate_shape=validate_shape, use_resource=use_resource)
368
369 def _get_partitioned_variable(
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in _true_getter(name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, use_resource)
350 trainable=trainable, collections=collections,
351 caching_device=caching_device, validate_shape=validate_shape,
--> 352 use_resource=use_resource)
353
354 if custom_getter is not None:
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in _get_single_variable(self, name, shape, dtype, initializer, regularizer, partition_info, reuse, trainable, collections, caching_device, validate_shape, use_resource)
662 " Did you mean to set reuse=True in VarScope? "
663 "Originally defined at:\n\n%s" % (
--> 664 name, "".join(traceback.format_list(tb))))
665 found_var = self._vars[name]
666 if not shape.is_compatible_with(found_var.get_shape()):
ValueError: Variable generator/g_wconv1 already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
File "<ipython-input-15-b5a26c2e15ce>", line 18, in generator
initializer=tf.truncated_normal_initializer(stddev=0.1))
File "<ipython-input-23-63a9b9a0b87e>", line 2, in <module>
Gz = generator(z_placeholder, batch_size, z_dimensions) #Gz holds the generated images
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
I am using the latest version of tensorflow and i get this error when i try to run any sort of GAN code.
It always happens when i reach this part of the code (any gan code):
trainerD = tf.train.AdamOptimizer().minimize(d_loss, var_list=d_vars)
and when i run it again and again the Adam_7 number goes up one more!
Also i ran your code as is. Could you help me with this issue? Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.