Week3 Assignment2 - problem with yolo_eval

  • Week3 Convolutional Neural Networks
  • Link to the classroom item you are referring to:
  • Hi! Iam having an ‘unmatching shape’ error with the yolo_eval() function. The error basically says :
    “InvalidArgumentError: Incompatible shapes: [1786,3] vs. [1,4] [Op:Mul]”
    and the traceback at some point refers back to the line of code that rescales the boxes to fit the test set image shape. It seems like the problem is that the shape of the variable ‘boxes’ doesn’t match that of ‘image_dims’ used in the implementation of the ‘scale_boxes()’ function. I have checked the code multiple times but I don’t really see where this could come from. Thank you any suggestion.
    I am also trying to get a fresh copy of the notebook (in case I might accidentally have modified some of the code I shouldn’t). I tried clicking on the ‘instructions’ link at the top in the notebook but this simply leads to the week 3 course overview page.

You have filed this in the wrong category. The YOLO assignment is DLS ConvNets Week 3, not DLS Sequence Models Week 4. And you mentioned scaled_dot_product_attention in the title, which has nothing to do with YOLO.

To get a fresh copy of the notebook, here’s a thread with detailed instructions.

I added print statements to my code to show all the shapes in yolo_eval and here’s what I see:

box_confidence.shape (19, 19, 5, 1)
box_class_probs.shape (19, 19, 5, 80)
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'>
sum(filtering_mask) = 1786
boxes.shape (1786, 4) before scale_boxes
image_shape (720, 1280)
boxes.shape (1786, 4) after scale_boxes
scores[2] = 171.60194
boxes[2] = [-1240.3483 -3212.5881  -645.78    2024.3052]
classes[2] = 16
scores.shape = (10,)
boxes.shape = (10, 4)
classes.shape = (10,)
 All tests passed!

Please compare that to what you are getting and that should shed some light on where the issue is. One general thing to note is that it does not work to copy an old solution to this problem, because they changed some of the APIs here in April 2021.

Hi @paulinpaloalto, you’re right I mistakenly posted this problem in the wrong thread. I apologize for the confusion.

I moved it for you by using the little “edit pencil” on the title.

Were the suggestions I gave enough to help with the actual problem or are you still working on it?

Hi @paulinpaloalto , I apologize for this much delayed answer. My subscription to the course came to an end and it took some time before I could renew it. I am still working on it. But at this point I haven’t got much idea what could be the problem. Maybe I can send you a capture of my code in a direct message.

Sure, I will send you a DM about how to do that.