Concolutional Networks Week 3. Assignment 1, exercies one

I follow the instructions to compute the mask

filtering_mask = (box_class_scores >= threshold)

TypeError: Cannot convert 0.5 to EagerTensor of dtype int64

Any idea why it is doing that?

Thanks

That is a common problem. It means the type of your box_class_scores tensor is wrong. You are probably mixing up the classes and the scores. The classes are integer values, but the scores are not.

I added a bunch of instrumentation to my code for that section. Here’s what I see with correct code:

boxes.shape (19, 19, 5, 4)
boxes.dtype <dtype: 'float32'>
box_scores.shape (19, 19, 5, 80)
box_scores.dtype <dtype: 'float32'>
box_classes.shape (19, 19, 5)
box_classes.dtype <dtype: 'int64'>
box_class_scores.shape (19, 19, 5)
box_class_scores.dtype <dtype: 'float32'>
filtering_mask.shape (19, 19, 5)
filtering_mask.dtype <dtype: 'bool'>
scores[2] = 9.270486
boxes[2] = [ 4.6399336  3.2303846  4.431282  -2.202031 ]
classes[2] = 8
scores.shape = (1789,)
boxes.shape = (1789, 4)
classes.shape = (1789,)
 All tests passed!

You could always give search a try…

https://community.deeplearning.ai/search?q=TypeError%3A%20Cannot%20convert%200.5%20to%20EagerTensor%20of%20dtype%20int64