Exercise 1 - yolo_filter_boxes Assignement 1 W3

Hello,

I’m getting this error when compiling the code “Cannot convert 0.5 to EagerTensor of dtype int64”.

Throught my research on the forum, it apears that the mask shoudl be created based on box_class_scores, but those represent the classes which are intergers from 1 to 80.

So the logic says that the mask should be applied the box_classes ( because here we have the maximum of box scores and this maximum is float between 0 and 1.

But i get the error after applying this.

Thanks for your help.

I think you have classes and scores reversed in your thinking there (at least in your first statement). The classes are integers, but the scores are the floating point values, right?

I added a bunch of print statements to my logic for yolo_filter_boxes to show the shapes and types of everything. Here’s what I see:

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!

Yes, it is
classes are intergers from 1 to 80
and scores are floats between 0 and 1
right ?

When I print the box_class_scores of the example given it returs floats > 1 that’s what I don’t get:

array([[[ 7.8824973 , 15.941693 , 9.270486 , 10.659197 ,
11.924357 ],
[ 90.77388 , 5.974023 , 1.8933523 , 29.829315 ,
31.208069 ],
[ 6.537015 , 41.7416 , 23.049517 , 37.349552 ,
13.52168 ],
…,
[ 62.409065 , 33.47416 , 11.878175 , 59.977737 ,
21.68427 ],
[ 10.253807 , 50.624313 , 71.08136 , 21.55704 ,
20.643707 ],
[ 44.418617 , 6.1362724 , 39.162514 , 53.065334 ,
17.46208 ]],

Thank you in advance for your help

Yes, that’s a good point. I noticed that just now also. I think this is because the input data that they feed us as the test case is wrong. Notice that they initialize the input value box_class_probs as a tensor of values from a Gaussian distribution with \mu = 1 and \sigma = 4. I think they should be from the Uniform Distribution on [0,1], but maybe I’m missing something here. Note that as a test case, it doesn’t really matter: nothing in the logic of this particular function fundamentally depends on those values looking like probabilities.

So it’s probably valid as a test case, but doesn’t make much sense. I’ll file a bug about this or maybe look a bit harder to make sure we’re not just missing something here.

Thank you,

I got the test right and passed but I was stuck understanding this point.

Thank you again for checking and responding