deep_features icon indicating copy to clipboard operation
deep_features copied to clipboard

ValueError: Shape must be rank 4 but is rank 3 for 'simple_nms/MaxPoolV2'

Open mobiiin opened this issue 4 years ago • 2 comments

hi After following the instruction, I installed it in a Python 3 workspace however when I run rosrun feature_extraction feature_extraction_node.py

I get the following error:

2021-09-02 15:58:06.602657: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1628, in _create_c_op
    c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 4 but is rank 3 for 'simple_nms/MaxPoolV2' (op: 'MaxPoolV2') with input shapes: [1,?,1], [4], [4].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mobiiin/catkin_ws/src/deep_features/feature_extraction/feature_extraction_node.py", line 200, in <module>
    main()
  File "/home/mobiiin/catkin_ws/src/deep_features/feature_extraction/feature_extraction_node.py", line 42, in main
    net = FeatureNet()
  File "/home/mobiiin/git/deep_features/feature_extraction/hfnet_tf.py", line 38, in __init__
    config['nms_iterations'], config['nms_radius'])
  File "/home/mobiiin/git/deep_features/feature_extraction/hfnet_tf.py", line 80, in select_keypoints
    scores = self.simple_nms(scores, nms_iterations, nms_radius)
  File "/home/mobiiin/git/deep_features/feature_extraction/hfnet_tf.py", line 69, in simple_nms
    max_mask = tf.equal(scores, max_pool(scores))
  File "/home/mobiiin/git/deep_features/feature_extraction/hfnet_tf.py", line 67, in <lambda>
    strides=[1, 1, 1, 1], padding='SAME')[..., 0]
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 5666, in max_pool_v2
    padding=padding, data_format=data_format, name=name)
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1792, in __init__
    control_input_ops)
  File "/home/mobiiin/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op
    raise ValueError(str(e))
ValueError: Shape must be rank 4 but is rank 3 for 'simple_nms/MaxPoolV2' (op: 'MaxPoolV2') with input shapes: [1,?,1], [4], [4].

ros melodic ubuntu 18 tensorflow cpu 1.12.0

ps: I also tried tensorflow 1.13.1 and 1.14 and 1.15 all led to the previous error also not a numpy issue

mobiiin avatar Aug 25 '21 08:08 mobiiin

Hi @mobiiin , sorry I do not have any hints about your issues. tf 1.14 should work, see environment.yml. And the code of simple_nms was copied from hfnet, which specifies tf 1.12, so 1.12 should also work in theory.

cedrusx avatar Sep 13 '21 04:09 cedrusx

Hello, I have also encountered the same problem. Have you resolved it!

wangy-w avatar May 17 '23 11:05 wangy-w