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

ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted []. #3752

Closed
ashiqks opened this issue Mar 26, 2018 · 13 comments

Comments

@ashiqks
Copy link

ashiqks commented Mar 26, 2018

System information

  • What is the top-level directory of the model you are using: object_detection
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 7
  • TensorFlow installed from (source or binary):
    binary
  • TensorFlow version (use command below): 1.6.0
  • Bazel version (if compiling from source): No
  • CUDA/cuDNN version: No
  • GPU model and memory: No
  • Exact command to reproduce: python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_resnet_v2_atrous_coco_2018_01_28.config

While running with the pre-trained object_detection every model with Anaconda python 3.6.4 below given error is shown with the new version Tensorflow 1.6.0

Traceback (most recent call last): File "train.py", line 167, in <module> tf.app.run() File "C:\Users\MAT\Anaconda3\lib\site-packages\tensorflow\python\platform\app. py", line 126, in run _sys.exit(main(argv)) File "train.py", line 163, in main worker_job_name, is_chief, FLAGS.train_dir) File "C:\Users\MAT\models-master\research\object_detection\trainer.py", line 2 55, in train train_config.optimizer) File "C:\Users\MAT\models-master\research\object_detection\builders\optimizer_ builder.py", line 50, in build learning_rate = _create_learning_rate(config.learning_rate) File "C:\Users\MAT\models-master\research\object_detection\builders\optimizer_ builder.py", line 109, in _create_learning_rate learning_rate_sequence, config.warmup) File "C:\Users\MAT\models-master\research\object_detection\utils\learning_sche dules.py", line 169, in manual_stepping [0] * num_boundaries)) File "C:\Users\MAT\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops .py", line 2619, in where return gen_math_ops._select(condition=condition, x=x, y=y, name=name) File "C:\Users\MAT\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ ops.py", line 4503, in _select "Select", condition=condition, t=x, e=y, name=name) File "C:\Users\MAT\Anaconda3\lib\site-packages\tensorflow\python\framework\op_ def_library.py", line 528, in _apply_op_helper (input_name, err)) ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

@nehcgnem
Copy link

I got the same issue

@lcerman
Copy link

lcerman commented Mar 26, 2018

I hit this too while training faster_rcnn_resnet101_coco_2017_11_08 with TF 1.6. Also tried 1.5.1, throws the same error. I am on Ubuntu 16.04.

Edit: I have previously been using TF 1.4.1 with some older revision of tf-models without any problem, now I wanted to use newer TF so I upgraded to TF 1.6 and grabbed the latest tf-models master (08af777).

Edit 2: the error occurs also when attempting to fine tune the latest relase faster_rcnn_resnet101_coco_2018_01_28.

@lcerman
Copy link

lcerman commented Mar 27, 2018

Seems to be Python 3 compatibility issue, found solution here: #3705 (comment)

@ashiqks
Copy link
Author

ashiqks commented Mar 27, 2018

@lcerman, I made the change as you suggested and it worked. Thanks.

@SaimaNasirOfficial
Copy link

@ashiqgiga Hi can you please tell me which solution you followed?

@Ron-Junior
Copy link

i have the same error, and change both files learning_schedules like the solution #3705 (comment) but keep error:

INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
WARNING:tensorflow:From C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\trainer.py:228: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:depth of additional conv before box predictor: 0
WARNING:tensorflow:From C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\core\box_predictor.py:396: calling reduce_mean (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
WARNING:tensorflow:From C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\core\losses.py:316: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See tf.nn.softmax_cross_entropy_with_logits_v2.

Traceback (most recent call last):
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1036, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 235, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 442, in make_tensor_proto
_GetDenseDimensions(values)))
ValueError: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 524, in _apply_op_helper
values, as_ref=input_arg.is_ref).dtype.name
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1036, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 235, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 442, in make_tensor_proto
_GetDenseDimensions(values)))
ValueError: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "train.py", line 167, in
tf.app.run()
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
_sys.exit(main(argv))
File "train.py", line 163, in main
worker_job_name, is_chief, FLAGS.train_dir)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\trainer.py", line 255, in train
train_config.optimizer)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\optimizer_builder.py", line 50, in build
learning_rate = _create_learning_rate(config.learning_rate)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\optimizer_builder.py", line 109, in _create_learning_rate
learning_rate_sequence, config.warmup)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\utils\learning_schedules.py", line 169, in manual_stepping
[0] * num_boundaries))
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\ops\array_ops.py", line 2619, in where
return gen_math_ops._select(condition=condition, x=x, y=y, name=name)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 4503, in _select
"Select", condition=condition, t=x, e=y, name=name)
File "C:\Users\Ronaldo\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 528, in _apply_op_helper
(input_name, err))
ValueError: Tried to convert 't' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

@ashiqks
Copy link
Author

ashiqks commented Mar 28, 2018

@Saima321 I followed the solution of the issue #3705 commented by icerman.

@Ron-Junior
Copy link

I modified the file learning_schedules.py in path the anaconda. works for me

@yanggreen
Copy link

@Ron-Junior
I have the same error with u.
Can u share how to modify the file learning_schedules.py in path the anaconda?

@yanggreen
Copy link

If you change the file learning_schedules like the solution #3705 still got the same error.
please run the following commands in your tensorflow path

\models\research> python setup.py build
\models\research> python setup.py install

It works for me.

@dwleeKAIST
Copy link

dwleeKAIST commented Apr 27, 2018

In my case, the following edits solves my error.
net_out = myNetwork(input)
loss = tf.losses.mean_squared_error(target, net_out)
--->
net_out = myNetwork(input)
loss = tf.losses.mean_squared_error(target, net_out.outputs)

Here, 'net_out', itself, is not a output result of the network.
Thus, we need to use 'net_out.outputs' instead.

The following tutorials for tensorlayer helped to solve this issue in my case.
http://tensorlayer.readthedocs.io/en/latest/user/tutorial.html#understand-the-mnist-example

@medasuryatej
Copy link

Followed #3705 was able to train using CPU, but tensorflow gpu throwed lot of new errors

@tensorflowbutler
Copy link
Member

Hi There,
We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing.
If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.

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

9 participants