Yolo_filter_boxes tf.boolean_mask shapes are incompatible

In the course 4 week 3 programming assignment 1, yolo_filter_boxes method, I am facing the dimension mismatch issue with the tf.boolean_mask method. What could I be doing/calculating wrong to face this issue ? Thanks in advance.Here is my exception trace:

ValueError Traceback (most recent call last)
in
4 boxes = tf.random.normal([19, 19, 5, 4], mean=1, stddev=4, seed = 1)
5 box_class_probs = tf.random.normal([19, 19, 5, 80], mean=1, stddev=4, seed = 1)
----> 6 scores, boxes, classes = yolo_filter_boxes(boxes, box_confidence, box_class_probs, threshold = 0.5)
7 print("scores[2] = " + str(scores[2].numpy()))
8 print("boxes[2] = " + str(boxes[2].numpy()))

in yolo_filter_boxes(boxes, box_confidence, box_class_probs, threshold)
49 print(box_classes.shape)
50 scores =tf.boolean_mask(box_class_scores, filtering_mask)
β€”> 51 boxes = tf.boolean_mask(boxes, filtering_mask)
52 classes = tf.boolean_mask(box_classes, filtering_mask)
53 ### END CODE HERE

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 β€œβ€β€œCall target, and fall back on dispatchers if there is a TypeError.”""
200 try:
β†’ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in boolean_mask_v2(tensor, mask, axis, name)
1801 ```
1802 β€œβ€"
β†’ 1803 return boolean_mask(tensor, mask, name, axis)
1804
1805

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 β€œβ€β€œCall target, and fall back on dispatchers if there is a TypeError.”""
200 try:
β†’ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in boolean_mask(tensor, mask, name, axis)
1728 if axis_value is not None:
1729 axis = axis_value
β†’ 1730 shape_tensor[axis:axis + ndims_mask].assert_is_compatible_with(shape_mask)
1731
1732 leading_size = gen_math_ops.prod(shape(tensor)[axis:axis + ndims_mask], [0])

/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in assert_is_compatible_with(self, other)
1132 β€œβ€"
1133 if not self.is_compatible_with(other):
β†’ 1134 raise ValueError("Shapes %s and s are incompatible" (self, other))
1135
1136 def most_specific_compatible_shape(self, other):

ValueError: Shapes (19, 19, 5, 4) and (19, 19, 5, 80) are incompatible

Have you read through any of these…
https://community.deeplearning.ai/search?q=Filtering_mask%20%23deep-learning-specialization:dls-course-4

1 Like