Course 4 W3 assignment 1: problem with filtering

I am stuck in this assignment as I do not seem to get Step 3: Create a filtering mask correct. I am getting error “TypeError: Cannot convert 0.5 to EagerTensor of dtype int64”.

Can you have a look at my code to see what is causing the issue? My lab id is ezjuxtgbwbpt

We can’t see your code directly. There are ways to share it privately. But this is a question that has come up many times before. I added a bunch of print statements to my code to show the shape and type of everything in that test case. Please have a look at this and compare to what your code produces:

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) = 1789
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!

Either your box_class_scores is the wrong type or perhaps you are comparing against the classes instead of the scores.

1 Like

Or if you are asking about yolo_eval, here is my corresponding output for that test cell:

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
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!
1 Like

Thank you! This helped me to find the error in the code.