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
eval_image_classifier.py can't predict top 5 accuracy #694
Comments
if remove out the line: 'Recall@5': slim.metrics.streaming_recall_at_k( I can still get top 1 accuracy without any error. |
Thanks for that! I was seeing a similar error after fine tuning If it helps, my error is as follows (on TensorFlow r0.11 Linux/CPU):
|
Same issue with me also. I am using flower dataset for fine tuning. It gives me same error except targets[3] out of range in error. using tensorflow rc11, python 2.7 and CentOS 7 without GPU |
Change |
Does @salikapur's suggestion resolve your issue? |
seems not, for my 2 categories finetune train, afer changing to ValueError: input must have last dimension >= k = 5 but is 2 for 'recall_at_5/TopKV2' (op: 'TopKV2') with input shapes: [32,2], [] and with computed input tensors: input[1] = <5>. |
With just 2 labels I dont think you can calculate top 5 error. I think just top 1 error should suffice for your case. |
Change It works!! |
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks! |
predictions = tf.argmax(logits, 1)
|
I get the following error when run eval_image_classifier.py to test inception v2 .ckpt file: I am using the latest code and run a data set which has 269 class labels.
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors.InvalidArgumentError'>, targets[86] is out of range
[[Node: InTopK = InTopK[T=DT_INT64, k=5, _device="/job:localhost/replica:0/task:0/cpu:0"](InceptionV2/Logits/SpatialSqueeze/_1161, Squeeze/_1163)]]
[[Node: InTopK/_1165 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_322_InTopK", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/gpu:0"]]
Caused by op u'InTopK', defined at:
File "eval_image_classifier.py", line 191, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "eval_image_classifier.py", line 157, in main
logits, labels, 5),
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/framework/deprecation.py", line 218, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/metrics/python/ops/metric_ops.py", line 1277, in streaming_recall_at_k
in_top_k = math_ops.to_float(nn.in_top_k(predictions, labels, k))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 1290, in in_top_k
targets=targets, k=k, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1298, in init
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): targets[86] is out of range
[[Node: InTopK = InTopK[T=DT_INT64, k=5, _device="/job:localhost/replica:0/task:0/cpu:0"](InceptionV2/Logits/SpatialSqueeze/_1161, Squeeze/_1163)]]
[[Node: InTopK/_1165 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_322_InTopK", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/gpu:0"]]
Traceback (most recent call last):
File "eval_image_classifier.py", line 191, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "eval_image_classifier.py", line 187, in main
variables_to_restore=variables_to_restore)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/evaluation.py", line 359, in evaluate_once
global_step=global_step)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim/python/slim/evaluation.py", line 260, in evaluation
sess.run(eval_op, eval_op_feed_dict)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 717, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 915, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 985, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.InvalidArgumentError: targets[86] is out of range
[[Node: InTopK = InTopK[T=DT_INT64, k=5, _device="/job:localhost/replica:0/task:0/cpu:0"](InceptionV2/Logits/SpatialSqueeze/_1161, Squeeze/_1163)]]
[[Node: InTopK/_1165 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_322_InTopK", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/gpu:0"]]
Caused by op u'InTopK', defined at:
File "eval_image_classifier.py", line 191, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "eval_image_classifier.py", line 157, in main
logits, labels, 5),
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/framework/deprecation.py", line 218, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/metrics/python/ops/metric_ops.py", line 1277, in streaming_recall_at_k
in_top_k = math_ops.to_float(nn.in_top_k(predictions, labels, k))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 1290, in in_top_k
targets=targets, k=k, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1298, in init
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): targets[86] is out of range
[[Node: InTopK = InTopK[T=DT_INT64, k=5, _device="/job:localhost/replica:0/task:0/cpu:0"](InceptionV2/Logits/SpatialSqueeze/_1161, Squeeze/_1163)]]
[[Node: InTopK/_1165 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_322_InTopK", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/gpu:0"]]
The text was updated successfully, but these errors were encountered: