ValueError: operands could not be broadcast together with shapes (19,19,5,4) (19,19,5,80)
please help !
The error means that because those lists/tensors/arrays do not have the same shape then mathematical operations can not be performed. Try to arrange those such that they have the same shape!
Hey,
Yes,please check your code once for the shapes and if the error still exists then please do let us know
Hope this helps
Thanks and Regards,
Mayank Ghogale
You don’t say which function threw this error, but it’s a common problem. I’m guessing it’s yolo_filter_boxes. I added a bunch of print statements to my code and here’s what I see from the test cell for yolo_filter_boxes:
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!
Compare that to what you see and perhaps that will point you to where your code is going off the rails.
If that doesn’t get you there, it would be useful to actually see the full exception trace that you get when it fails.
This error is only occuring when I call yolo_eval function! I passed all the above tests! I tried your method and the vector shapes match so I can’t figure out what is the real issue
This error is only occuring when I call yolo_eval function! I passed all the above tests! I tried your method and the vector shapes match so I can’t figure out what is the real issue
Did you copy your solution from the Internet? If so, you might want to compare the way you are invoking the function yolo_filter_boxes when you call it from yolo_eval with the definition of that function. They changed the definition of that API in the April 2021 upgrade to these courses and old solutions you find on the Internet use a different API definition. The order of the arguments changed.
Thank you very much! Indeed it was the order placement that was throwing the error! resolved it!
I’m glad to hear that you were able to find the error. Just as a general matter, please note that copying code off the Internet is a) a violation of the rules and b) doesn’t always work, as in this case, and can thus end up just wasting your time. Please note that these courses were significantly changed in April of 2021, so there is no guarantee that solutions you find on the internet still work. They might be from the old version of the courses.
I am not really copying the code! I use it as a reference but then last block only involved calling the functions hence I didn’t bother writing it on my own! Will ensure that I don’t repeat this mistake! thank you!