Course 4 Week3 Exercise 1 yolo filter boxes

I am having trouble getting the yolo filter boxes.

I am getting scores by confidence*probs
getting the arg max of scores as classes
getting the reduce max of classes as class scores
making the filter to be scores >= threshold
applying the mask on the scores, boxes, and classes

I get the error Cannot convert 0.5 to EagerTensor of dtype int64

And if I divide box_class_scores by 100 (to get them <1 ) I get only 324 shape with
scores.shape = (324,)
boxes.shape = (324, 5, 4)
classes.shape = (324, 5)

which looks wrong. I canā€™t seem to see where I am going wrong based on hints and such though.

That most likely points to a syntax or similar error in your code. Itā€™s not ā€œwhatā€ youā€™re doing in the code thatā€™s wrong, itā€™s ā€œhowā€.

1 Like

I added some print statements to the yolo_filter_boxes code and hereā€™s what I see when I run the test cell for that function:

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'>
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!

One other general point to make is that you have to be careful if you are porting your solutions forward from the previous version of the course. Note that they changed the definition the yolo_filter_boxes function as well as some other things. You need to compare carefully if thatā€™s your situation. Just blindly copying things will not end well :scream_cat: ā€¦

Box scores shape : (19, 19, 5, 80)
Box scores type : <dtype: ā€˜float32ā€™>
Box_classes shape: (19, 19, 5)
Box_classes type: <dtype: ā€˜int64ā€™>
Box_class_Score shape: (19, 19)
Box_class_Score type: <dtype: ā€˜int64ā€™>

This is what I am getting so I must be doing box_class_score wrong.

The hint is a bit confusing to me

Step 2: Find the box_classes using the max box_scores, keep track of the corresponding score

##(ā‰ˆ 2 lines)

First line is argmax to find the biggest but then I donā€™t know what it means by keep track of score. So I did the reduce_max for the boxclass score of the box_classes, which I am just not understanding.

Oh just figured it outā€¦ Thanks for the help. I was putting in box classes instead of box scores for the box_class_scores

Cool! Iā€™m glad to hear you found the solution. Thanks for confirming.