Skip to content

ValueError: Variable fcn_8s/vgg_16/conv1/conv1_1/weights already exists, disallowed #2

Description

@amiltonwong

Hi, @warmspringwinds ,

I followed the steps from README.md. And start to run the first cell from fully_convolutional_networks.ipynb . However I got the following ValueError, could you suggest me how to fix this error?
(my environment: TF 0.12.1, python 2.7.13)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-4efcd9f3827b> in <module>()
     47 pred, fcn_16s_variables_mapping = FCN_8s(image_batch_tensor=image_batch_tensor,
     48                                           number_of_classes=number_of_classes,
---> 49                                           is_training=False)
     50 
     51 # The op for initializing the variables.

/data/code/Dan_segment/tf-image-segmentation/tf_image_segmentation/utils/inference.pyc in new_network_definition(*args, **kwargs)
     51         kwargs['image_batch_tensor'] = resized_images_batch
     52 
---> 53         all_outputs = network_definition(*args, **kwargs)
     54 
     55         all_outputs = list(all_outputs)

/data/code/Dan_segment/tf-image-segmentation/tf_image_segmentation/models/fcn_8s.pyc in FCN_8s(image_batch_tensor, number_of_classes, is_training)
     77                                                        is_training=is_training,
     78                                                        spatial_squeeze=False,
---> 79                                                        fc_conv_padding='SAME')
     80 
     81 

/data/code/Dan_segment/models/slim/nets/vgg.pyc in vgg_16(inputs, num_classes, is_training, dropout_keep_prob, spatial_squeeze, scope, fc_conv_padding)
    164     with slim.arg_scope([slim.conv2d, slim.fully_connected, slim.max_pool2d],
    165                         outputs_collections=end_points_collection):
--> 166       net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1')
    167       net = slim.max_pool2d(net, [2, 2], scope='pool1')
    168       net = slim.repeat(net, 2, slim.conv2d, 128, [3, 3], scope='conv2')

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.pyc in repeat(inputs, repetitions, layer, *args, **kwargs)
   1668     for i in range(repetitions):
   1669       kwargs['scope'] = scope + '_' + str(i+1)
-> 1670       outputs = layer(outputs, *args, **kwargs)
   1671     return outputs
   1672 

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
    175       current_args = current_scope[key_func].copy()
    176       current_args.update(kwargs)
--> 177     return func(*args, **current_args)
    178   _add_op(func)
    179   setattr(func_with_args, '_key_op', _key_op(func))

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.pyc in convolution(inputs, num_outputs, kernel_size, stride, padding, data_format, rate, activation_fn, normalizer_fn, normalizer_params, weights_initializer, weights_regularizer, biases_initializer, biases_regularizer, reuse, variables_collections, outputs_collections, trainable, scope)
    838                                        regularizer=weights_regularizer,
    839                                        collections=weights_collections,
--> 840                                        trainable=trainable)
    841     outputs = nn.convolution(input=inputs,
    842                              filter=weights,

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
    175       current_args = current_scope[key_func].copy()
    176       current_args.update(kwargs)
--> 177     return func(*args, **current_args)
    178   _add_op(func)
    179   setattr(func_with_args, '_key_op', _key_op(func))

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.pyc in model_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device)
    242                   initializer=initializer, regularizer=regularizer,
    243                   trainable=trainable, collections=collections,
--> 244                   caching_device=caching_device, device=device)
    245 
    246 

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
    175       current_args = current_scope[key_func].copy()
    176       current_args.update(kwargs)
--> 177     return func(*args, **current_args)
    178   _add_op(func)
    179   setattr(func_with_args, '_key_op', _key_op(func))

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.pyc in variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device)
    206                                        trainable=trainable,
    207                                        collections=collections,
--> 208                                        caching_device=caching_device)
    209 
    210 

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
   1022       collections=collections, caching_device=caching_device,
   1023       partitioner=partitioner, validate_shape=validate_shape,
-> 1024       custom_getter=custom_getter)
   1025 
   1026 

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, var_store, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
    848           collections=collections, caching_device=caching_device,
    849           partitioner=partitioner, validate_shape=validate_shape,
--> 850           custom_getter=custom_getter)
    851 
    852   def _get_partitioned_variable(self,

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
    344           reuse=reuse, trainable=trainable, collections=collections,
    345           caching_device=caching_device, partitioner=partitioner,
--> 346           validate_shape=validate_shape)
    347 
    348   def _get_partitioned_variable(

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in _true_getter(name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape)
    329           initializer=initializer, regularizer=regularizer, reuse=reuse,
    330           trainable=trainable, collections=collections,
--> 331           caching_device=caching_device, validate_shape=validate_shape)
    332 
    333     if custom_getter is not None:

/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-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)
    630                          " Did you mean to set reuse=True in VarScope? "
    631                          "Originally defined at:\n\n%s" % (
--> 632                              name, "".join(traceback.format_list(tb))))
    633       found_var = self._vars[name]
    634       if not shape.is_compatible_with(found_var.get_shape()):

ValueError: Variable fcn_8s/vgg_16/conv1/conv1_1/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:

  File "/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 208, in variable
    caching_device=caching_device)
  File "/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/root/anaconda2/envs/python_2.7_tf_0.12/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 244, in model_variable
    caching_device=caching_device, device=device)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions