Mask_rcnn: TypeError: unsupported operand type(s) for /: 'Tensor' and 'float'

Created on 31 Dec 2017  ·  11Comments  ·  Source: matterport/Mask_RCNN

Hi,i am a new to tf and keras.I run Mask_RCNN-2.0 .when i debug the project,i meet a problem.But i dont understand it likeing this:
Traceback (most recent call last):
File "/home/whao/pycharm-2017.1.2/helpers/pydev/pydevd.py", line 1585, in
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/whao/pycharm-2017.1.2/helpers/pydev/pydevd.py", line 1015, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/whao/pycharm-2017.1.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"n", file, 'exec'), glob, loc)
File "/home/whao/Mask_RCNN-2.0/coco.py", line 382, in
model_dir=args.logs)
File "/home/whao/Mask_RCNN-2.0/model.py", line 1735, in __init__
self.keras_model = self.build(mode=mode, config=config)
File "/home/whao/Mask_RCNN-2.0/model.py", line 1875, in build
target_rois, input_gt_class_ids, gt_boxes, input_gt_masks])
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 603, in __call__
output = self.call(inputs, *kwargs)
File "/home/whao/Mask_RCNN-2.0/model.py", line 636, in call
self.config.IMAGES_PER_GPU, names=names)
File "/home/whao/Mask_RCNN-2.0/utils.py", line 673, in batch_slice
output_slice = graph_fn(
inputs_slice)
File "/home/whao/Mask_RCNN-2.0/model.py", line 635, in
w, x, y, z, self.config),
File "/home/whao/Mask_RCNN-2.0/model.py", line 531, in detection_targets_graph
negative_count = int((positive_count / config.ROI_POSITIVE_RATIO) - positive_count)
TypeError: unsupported operand type(s) for /: 'Tensor' and 'float'

why the int32 of tensor can operand to the float constant:
positive_count = tf.shape(positive_indices)[0]
# Negative ROIs. Add enough to maintain positive:negative ratio.
negative_count = int((positive_count / config.ROI_POSITIVE_RATIO) - positive_count)

it differs from the first version:
r = 1.0 / config.ROI_POSITIVE_RATIO
negative_count = tf.cast(r * tf.cast(positive_count, tf.float32), tf.int32) - positive_count
What should i do to be able to do that like Mask_RCNN-2.0?

Most helpful comment

@WanyiLi Yes,i solved it.You can solve it by viewing the code of the first version.

All 11 comments

I met the same problem. Have you solved it?

@WanyiLi Yes,i solved it.You can solve it by viewing the code of the first version.

@76176235 Yeah, I got it. Thank you very much!

@76176235 @WanyiLi I am getting same error !

I am sorry, i can not solve the problem, can you make it more details?

@76176235 @WanyiLi hi, guys! Can you say by steps how to solve it, please? I can't understand what words "You can solve it by viewing the code of the first version" mean. Should I use this part of code from the first version in version 2.0??
upd: I've done it, but the problem still the same: TypeError: unsupported operand type(s) for /: 'Tensor' and 'float'
now it's on r = _1.0_ / config.ROI_POSITIVE_RATIO

you can through the error to find the different between the first version and the second version.2018-04-02 17:08:38>MNCTTY 写道:

@76176235@WanyiLi hi, guys! Can you say by steps how to solve it, please? I can't understand what words "You can solve it by viewing the code of the first version" mean. Should I use this part of code from the first version in version 2.0??
Thank you


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

what a pity! I also meet the same error. I can't understand how to solve the error.Can you say by steps how to solve it, please? @WanyiLi thanks !

Now,the version of code is Mask R-CNN 2.1. You can avoid this error ,while you compile Mask R-CNN 1.0 .

@76176235 thanks,i will have a try!

@76176235 ,cool man, I solved my error,hh!

Was this page helpful?
0 / 5 - 0 ratings