llSourcell / GANS-for-style-transfer

64 stars 38 forks source link

ValueError: Variable inference/Repeat/fully_connected_1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? #5

Open banji007 opened 7 years ago

banji007 commented 7 years ago

Getting this error... ValueError: Variable inference/Repeat/fully_connected_1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope?

---> 14 rec_z = inference_network(p_x, latent_dim, n_layer_inf, n_hidden_inf, eps_dim ) 16 rec_x = generative_network(q_z, input_dim , n_layer_gen, n_hidden_gen, eps_dim ) 15 rec_x = generative_network(q_z, input_dim , n_layer_gen, n_hidden_gen, eps_dim )

c:\python36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py in repeat(inputs, repetitions, layer, *args, *kwargs) 2058 for i in range(repetitions): 2059 kwargs['scope'] = scope + '_' + str(i+1) -> 2060 outputs = layer(outputs, args, **kwargs) 2061 return outputs 2062

c:\python36\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py in func_with_args(*args, *kwargs) 179 current_args = current_scope[key_func].copy() 180 current_args.update(kwargs) --> 181 return func(args, **current_args) 182 _add_op(func) 183 setattr(func_with_args, '_key_op', _key_op(func))

c:\python36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py in fully_connected(inputs, num_outputs, activation_fn, normalizer_fn, normalizer_params, weights_initializer, weights_regularizer, biases_initializer, biases_regularizer, reuse, variables_collections, outputs_collections, trainable, scope) 1659 _scope=sc, 1660 _reuse=reuse) -> 1661 outputs = layer.apply(inputs) 1662 1663 # Add variables to collections.

c:\python36\lib\site-packages\tensorflow\python\layers\base.py in apply(self, inputs, *args, *kwargs) 501 Output tensor(s). 502 """ --> 503 return self.call(inputs, args, **kwargs) 504 505 def _assert_input_compatibility(self, inputs):

c:\python36\lib\site-packages\tensorflow\python\layers\base.py in call(self, inputs, *args, **kwargs) 441 input_shapes = [x.get_shape() for x in input_list] 442 if len(input_shapes) == 1: --> 443 self.build(input_shapes[0]) 444 else: 445 self.build(input_shapes)

c:\python36\lib\site-packages\tensorflow\python\layers\core.py in build(self, input_shape) 116 regularizer=self.kernel_regularizer, 117 dtype=self.dtype, --> 118 trainable=True) 119 if self.use_bias: 120 self.bias = self.add_variable('bias',

c:\python36\lib\site-packages\tensorflow\python\layers\base.py in add_variable(self, name, shape, dtype, initializer, regularizer, trainable) 381 initializer=initializer, 382 dtype=dtypes.as_dtype(dtype), --> 383 trainable=trainable and self.trainable) 384 if variable in existing_variables: 385 return variable

c:\python36\lib\site-packages\tensorflow\python\ops\variable_scope.py 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

c:\python36\lib\site-packages\tensorflow\python\ops\variable_scope.py 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,

c:\python36\lib\site-packages\tensorflow\python\ops\variable_scope.py in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, use_resource, custom_getter) 358 reuse=reuse, trainable=trainable, collections=collections, 359 caching_device=caching_device, partitioner=partitioner, --> 360 validate_shape=validate_shape, use_resource=use_resource) 361 else: 362 return _true_getter(

c:\python36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py in layer_variable_getter(getter, *args, kwargs) 1559 def layer_variable_getter(getter, *args, *kwargs): 1560 kwargs['rename'] = rename -> 1561 return _model_variable_getter(getter, args, kwargs) 1562 return layer_variable_getter 1563

c:\python36\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py in _model_variable_getter(getter, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, rename, useresource, **) 1551 regularizer=regularizer, collections=collections, trainable=trainable, 1552 caching_device=caching_device, partitioner=partitioner, -> 1553 custom_getter=getter, use_resource=use_resource) 1554 1555

c:\python36\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py in func_with_args(*args, *kwargs) 179 current_args = current_scope[key_func].copy() 180 current_args.update(kwargs) --> 181 return func(args, **current_args) 182 _add_op(func) 183 setattr(func_with_args, '_key_op', _key_op(func))

c:\python36\lib\site-packages\tensorflow\contrib\framework\python\ops\variables.py in model_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter, use_resource) 259 caching_device=caching_device, device=device, 260 partitioner=partitioner, custom_getter=custom_getter, --> 261 use_resource=use_resource) 262 return var 263

c:\python36\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py in func_with_args(*args, *kwargs) 179 current_args = current_scope[key_func].copy() 180 current_args.update(kwargs) --> 181 return func(args, **current_args) 182 _add_op(func) 183 setattr(func_with_args, '_key_op', _key_op(func))

c:\python36\lib\site-packages\tensorflow\contrib\framework\python\ops\variables.py in variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter, use_resource) 214 caching_device=caching_device, 215 partitioner=partitioner, --> 216 use_resource=use_resource) 217 218

c:\python36\lib\site-packages\tensorflow\python\ops\variable_scope.py 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:

c:\python36\lib\site-packages\tensorflow\python\ops\variable_scope.py 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 inference/Repeat/fully_connected_1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:

File "c:\python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access File "c:\python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op original_op=self._default_original_op, op_def=op_def) File "c:\python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op op_def=op_def)

owoshch commented 6 years ago

ValueError: Variable inference/Repeat/fully_connected_1/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at: ..

The same error in my case. Let me know please if you find the solution.

owoshch commented 6 years ago

Solved. This code is not compatible with tensorflow 1.4.0 so you need tensorflow 1.0 installed. You can do it via: pip install tensorflow==1.0