最近在复现别人代码的时候,遇到如下问题:
Traceback (most recent call last): ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call ??? return fn(*args) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn ??? target_list, run_metadata) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun ??? run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[0] = 82620 is not in [0, 81648) ?? ? [[{{node ROI/GatherV2_2}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): ? File "/home/robot/文档/ye/code/1dense-clutter-grasp-master/algorithm/detection_algorithm.py", line 407, in <module> ??? predict = GraspAlgorithm(parameters) ? File "/home/robot/文档/ye/code/1dense-clutter-grasp-master/algorithm/detection_algorithm.py", line 77, in __init__ ??? self.model.detect([null_image], verbose=1) ? File "/home/robot/文档/ye/code/1dense-clutter-grasp-master/algorithm/mrcnn/model.py", line 2544, in detect ??? self.keras_model.predict([molded_images, image_metas, anchors], verbose=0) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/keras/engine/training.py", line 1713, in predict ??? verbose=verbose, steps=steps) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/keras/engine/training.py", line 1269, in _predict_loop ??? batch_outs = f(ins_batch) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2273, in __call__ ??? **self.session_kwargs) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 956, in run ??? run_metadata_ptr) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1180, in _run ??? feed_dict_tensor, options, run_metadata) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1359, in _do_run ??? run_metadata) ? File "/home/robot/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/client/session.py", line 1384, in _do_call ??? raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[0] = 82620 is not in [0, 81648) ?? ? [[node ROI/GatherV2_2 (defined at /.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py:1748) ]]
Original stack trace for 'ROI/GatherV2_2': ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/detection_algorithm.py", line 407, in <module> ??? predict = GraspAlgorithm(parameters) ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/detection_algorithm.py", line 70, in __init__ ??? config=config_model) ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/mrcnn/model.py", line 1841, in __init__ ??? self.keras_model = self.build(mode=mode, config=config) ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/mrcnn/model.py", line 1969, in build ??? config=config)([rpn_class, rpn_bbox, anchors]) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/keras/engine/topology.py", line 602, in __call__ ??? output = self.call(inputs, **kwargs) ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/mrcnn/model.py", line 298, in call ??? names=["pre_nms_anchors"]) ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/mrcnn/utils.py", line 835, in batch_slice ??? output_slice = graph_fn(*inputs_slice) ? File "/文档/ye/code/1dense-clutter-grasp-master/algorithm/mrcnn/model.py", line 296, in <lambda> ??? pre_nms_anchors = utils.batch_slice([anchors, ix], lambda a, x: tf.gather(a, x), ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/util/dispatch.py", line 180, in wrapper ??? return target(*args, **kwargs) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/ops/array_ops.py", line 3956, in gather ??? params, indices, axis, name=name) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 4082, in gather_v2 ??? batch_dims=batch_dims, name=name) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper ??? op_def=op_def) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func ??? return func(*args, **kwargs) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 3357, in create_op ??? attrs, op_def, compute_device) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal ??? op_def=op_def) ? File "/.virtualenvs/tensor/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1748, in __init__ ??? self._traceback = tf_stack.extract_stack()
找了好久也没找到解决方法,最后发现一个类似的问题,解决方法是:在model.py中加上两行
mask = tf.greater(tf.shape(anchors)[1], ix, name="bool_mask")
ix = tf.stack([tf.boolean_mask(ix, mask)])
?
?
|