broadinstitute / keras-rcnn

Keras package for region-based convolutional neural networks (RCNNs)
Other
553 stars 224 forks source link

the model of rcnn's rpn classification_loss meet an error #171

Closed zzdang closed 6 years ago

zzdang commented 6 years ago

hi,when I use the rcnn model,the code occured an error in rpn classification_loss img_in = Input((None, None, 3)) rcnn_model = RCNN(img_in, 2) optimizer = keras.optimizers.Adam(0.0001) rcnn_model.compile(optimizer) the error is: Traceback (most recent call last): File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 686, in _call_cpp_shape_fn_impl input_tensors_as_shapes, status) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices.shape[-1] must be <= params.rank, but saw indices shape: [1,?,3] and params shape: [1,?] for 'rpn_1/GatherNd_1' (op: 'GatherNd') with input shapes: [1,?], [1,?,3].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test.py", line 84, in rcnn_model = RCNN(img_in, 2) File "/home/han/workplace/nuclei/keras-rcnn/keras_rcnn/models/_rcnn.py", line 66, in init output_deltas, output_scores = keras_rcnn.layers.RPN()([output_deltas, target_proposals, output_scores, target_proposal_labels]) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/keras/engine/topology.py", line 617, in call output = self.call(inputs, **kwargs) File "/home/han/workplace/nuclei/keras-rcnn/keras_rcnn/layers/losses/init.py", line 76, in call self.add_loss(self.classification_loss() + self.regression_loss()) File "/home/han/workplace/nuclei/keras-rcnn/keras_rcnn/layers/losses/init.py", line 88, in classification_loss output = keras_rcnn.backend.gather_nd(self.output_scores, indices) File "/home/han/workplace/nuclei/keras-rcnn/keras_rcnn/backend/tensorflow_backend.py", line 55, in gather_nd return tensorflow.gather_nd(params, indices) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1971, in gather_nd "GatherNd", params=params, indices=indices, name=name) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2958, in create_op set_shapes_for_outputs(ret) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs shapes = shape_func(op) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn require_shape_fn) File "/home/han/anaconda2/envs/keras_rcnn/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl raise ValueError(err.message) ValueError: indices.shape[-1] must be <= params.rank, but saw indices shape: [1,?,3] and params shape: [1,?] for 'rpn_1/GatherNd_1' (op: 'GatherNd') with input shapes: [1,?], [1,?,3].

thank you very much for helping me !

GuilhermeFSCampos commented 6 years ago

Got the same error trying the tutorial.

imparkss commented 6 years ago

Many people facing this problem maybe? I got too. and solved it by fixing simple ordering bug. i will pull request soon..

jhung0 commented 6 years ago

Yes, thanks for changing that.