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

Error on the provided ipython-notebook demo.ipynb to run the demo. #90

Open
sanjeewa894 opened this issue Jul 18, 2018 · 3 comments
Open

Comments

@sanjeewa894
Copy link


ValueError Traceback (most recent call last)
in ()
3 sfm.setup_inference(img_height,
4 img_width,
----> 5 mode='depth')

/home/sk/Desktop/sfmNN/Untitled Folder/Untitled Folder/SfMLearner.pyc in setup_inference(self, img_height, img_width, mode, seq_length, batch_size)
311 self.batch_size = batch_size
312 if self.mode == 'depth':
--> 313 self.build_depth_test_graph()
314 if self.mode == 'pose':
315 self.seq_length = seq_length

/home/sk/Desktop/sfmNN/Untitled Folder/Untitled Folder/SfMLearner.pyc in build_depth_test_graph(self)
268 with tf.name_scope("depth_prediction"):
269 pred_disp, depth_net_endpoints = disp_net(
--> 270 input_mc, is_training=False)
271 pred_depth = [1./disp for disp in pred_disp]
272 pred_depth = pred_depth[0]

/home/sk/Desktop/sfmNN/Untitled Folder/Untitled Folder/nets.pyc in disp_net(tgt_image, is_training)
82 activation_fn=tf.nn.relu,
83 outputs_collections=end_points_collection):
---> 84 cnv1 = slim.conv2d(tgt_image, 32, [7, 7], stride=2, scope='cnv1')
85 cnv1b = slim.conv2d(cnv1, 32, [7, 7], stride=1, scope='cnv1b')
86 cnv2 = slim.conv2d(cnv1b, 64, [5, 5], stride=2, scope='cnv2')

/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
181 current_args = current_scope[key_func].copy()
182 current_args.update(kwargs)
--> 183 return func(*args, **current_args)
184
185 _add_op(func)

/home/sk/.local/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)
1047 _scope=sc,
1048 _reuse=reuse)
-> 1049 outputs = layer.apply(inputs)
1050
1051 # Add variables to collections.

/home/sk/.local/lib/python2.7/site-packages/tensorflow/python/layers/base.pyc in apply(self, inputs, *args, **kwargs)
826 Output tensor(s).
827 """
--> 828 return self.call(inputs, *args, **kwargs)
829
830 def _add_inbound_node(self,

/home/sk/.local/lib/python2.7/site-packages/tensorflow/python/layers/base.pyc in call(self, inputs, *args, **kwargs)
697 if all(hasattr(x, 'get_shape') for x in input_list):
698 input_shapes = nest.map_structure(lambda x: x.get_shape(), inputs)
--> 699 self.build(input_shapes)
700 try:
701 # Note: not all sub-classes of Layer call Layer.init (especially

/home/sk/.local/lib/python2.7/site-packages/tensorflow/python/layers/convolutional.pyc in build(self, input_shape)
142 constraint=self.kernel_constraint,
143 trainable=True,
--> 144 dtype=self.dtype)
145 if self.use_bias:
146 self.bias = self.add_variable(name='bias',

/home/sk/.local/lib/python2.7/site-packages/tensorflow/python/layers/base.pyc in add_variable(self, name, shape, dtype, initializer, regularizer, trainable, constraint, partitioner)
544 constraint=constraint,
545 trainable=trainable and self.trainable,
--> 546 partitioner=partitioner)
547
548 if init_graph is not None: # pylint: disable=protected-access

/home/sk/.local/lib/python2.7/site-packages/tensorflow/python/training/checkpointable.pyc in _add_variable_with_custom_getter(self, name, shape, dtype, initializer, getter, overwrite, **kwargs_for_getter)
434 new_variable = getter(
435 name=name, shape=shape, dtype=dtype, initializer=initializer,
--> 436 **kwargs_for_getter)
437
438 # If we set an initializer and the variable processed it, tracking will not

/home/sk/.local/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, use_resource, custom_getter, constraint)
1315 partitioner=partitioner, validate_shape=validate_shape,
1316 use_resource=use_resource, custom_getter=custom_getter,
-> 1317 constraint=constraint)
1318 get_variable_or_local_docstring = (
1319 """%s

/home/sk/.local/lib/python2.7/site-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, constraint)
1077 partitioner=partitioner, validate_shape=validate_shape,
1078 use_resource=use_resource, custom_getter=custom_getter,
-> 1079 constraint=constraint)
1080
1081 def _get_partitioned_variable(self,

/home/sk/.local/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, use_resource, custom_getter, constraint)
415 if "constraint" in estimator_util.fn_args(custom_getter):
416 custom_getter_kwargs["constraint"] = constraint
--> 417 return custom_getter(**custom_getter_kwargs)
418 else:
419 return _true_getter(

/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.pyc in layer_variable_getter(getter, *args, **kwargs)
1609 def layer_variable_getter(getter, *args, **kwargs):
1610 kwargs['rename'] = rename
-> 1611 return _model_variable_getter(getter, *args, **kwargs)
1612
1613 return layer_variable_getter

/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.pyc in model_variable_getter(getter, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, rename, use_resource, **)
1600 partitioner=partitioner,
1601 custom_getter=getter,
-> 1602 use_resource=use_resource)
1603
1604

/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
181 current_args = current_scope[key_func].copy()
182 current_args.update(kwargs)
--> 183 return func(*args, **current_args)
184
185 _add_op(func)

/home/sk/.local/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, partitioner, custom_getter, use_resource)
289 caching_device=caching_device, device=device,
290 partitioner=partitioner, custom_getter=custom_getter,
--> 291 use_resource=use_resource)
292 return var
293

/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
181 current_args = current_scope[key_func].copy()
182 current_args.update(kwargs)
--> 183 return func(*args, **current_args)
184
185 _add_op(func)

/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.pyc in variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter, use_resource)
244 caching_device=caching_device,
245 partitioner=partitioner,
--> 246 use_resource=use_resource)
247
248

/home/sk/.local/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, use_resource, constraint)
392 trainable=trainable, collections=collections,
393 caching_device=caching_device, validate_shape=validate_shape,
--> 394 use_resource=use_resource, constraint=constraint)
395
396 if custom_getter is not None:

/home/sk/.local/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, use_resource, constraint)
731 "reuse=tf.AUTO_REUSE in VarScope? "
732 "Originally defined at:\n\n%s" % (
--> 733 name, "".join(traceback.format_list(tb))))
734 found_var = self._vars[name]
735 if not shape.is_compatible_with(found_var.get_shape()):

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

File "/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 246, in variable
use_resource=use_resource)
File "/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args
return func(*args, **current_args)
File "/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 291, in model_variable
use_resource=use_resource)

I have no idea to correct this error. Please give me some solution for this.

@Huang-Jin
Copy link
Contributor

DO NOT PUT SO MUCH OUTPUTS, IT IS VERY TERRIBLE to READ!
You just need to give us the final errors, like this

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

File "/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 246, in variable
use_resource=use_resource)
File "/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args
return func(*args, **current_args)
File "/home/sk/.local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 291, in model_variable
use_resource=use_resource)

@tothniki
Copy link

tothniki commented Oct 19, 2018

I also got this error.
For the very first run, the demo works fine, but after that, if you want to run the cells again, you will got this error.
The problem is that with the re-run it wants to reuse some variable (weights), but you can't do that.
(You can read about this here: https://www.tensorflow.org/guide/variables )

As you can read it in the error message:
ValueError: Variable depth_net/cnv1/weights already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope?

What you can do with this?
The solution for now (in the notebook):
You can go to Kernel->Restart & Clear Output.
With this you can run again the demo with a new Picture, etc...
But every time, when you want to run all over again, you have to restart the kernel :)

So guys please correct this Little Problem :)

@Huang-Jin
Copy link
Contributor

@tothniki Yes, you are right. I have to say that this error happened because of the reloading of tensorflow's model. So this might be an error of tensor flow in jupyter notebook mode.

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

3 participants