Course 4 week 3 assignment 1: yolo - error in yolo_filter_boxes

Hi! I am trying to finish yolo_filter_boxes, but have not been able to make it work. My shapes and dtypes are as follows (see below). As you can see, the scores, boxes and classes are of the wrong shape.

I am making sure that scores, boxes and classes are corresponding to “box_class_scores”, “boxes”, and “box_classes” respectively, and I am applying a mask to these tensors to get the final outputs.

Any suggestions?

Lab Id: kmxdqtur

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.shape: (16, 80)
scores.dtype: <dtype: ‘float32’>
boxes.shape: (16, 4)
boxes.dtype: <dtype: ‘float32’>
classes.shape: (16,)
classes.dtype: <dtype: ‘int64’>

I haven’t looked at this code for a long time, but it looks like your box_scores and box_classes are flipped. Classes should be 80, right? While scores is single valued.

Hi @ai_curious ,

The expected shapes are:

boxes.shape|(1789, 4)

As you can see, my shapes are totally different :frowning:


I’ve been able to solve this exercise of the lab. Thank you!

I was talking about the variables used prior to defining and applying the boolean. You wrote box_scores.shape: (19, 19, 5, 80) and box_classes.shape: (19, 19, 5) but it seemed to me that the classes object is the one that should have the 80 in it, while scores is a single floating point value for each grid cell + anchor box location ie (19,19,5)

If those aren’t the right shape, then the boolean mask and the final boxes, classes and scores won’t be either. But like I wrote, it has been a long time since I looked at the object detection code so maybe I got it wrong. Glad you got past it.