Error in Autonomous driving application car detection assignment

Hi,
I was attempting the YOLO assignment and hit a ‘roadblock’ in Exercise 4: yolo_eval. I was able to pass with 75% marks but despite going through the code several times I am unable to find the bug.
The error message I get is
InvalidArgumentError: Incompatible shapes: [19,19,5,80] vs. [19,19,5,4] [Op:Mul]

So I assume the problem is with the scale_boxes function. This is the line of code I’ve implemented just like in the instructions
boxes = scale_boxes(boxes, image_shape)

Can anyone help me with this please?

Thanks in advance
Prejith

hi @PreSam

can you share a screenshot of the complete error

surely there is a incompatibility in the shape but it could be a single bug affecting your grade as only one of the measurement shape mismatches.

can’t state much with just a single line error, but if there is a description of the error, mentors can have a bit more understanding.

Regards
DP

Thank you for the reply. This is the entire error code.

InvalidArgumentError Traceback (most recent call last)
in
5 tf.random.normal([19, 19, 5, 1], mean=1, stddev=4, seed = 1),
6 tf.random.normal([19, 19, 5, 80], mean=1, stddev=4, seed = 1))
----> 7 scores, boxes, classes = yolo_eval(yolo_outputs)
8 print("scores[2] = " + str(scores[2].numpy()))
9 print("boxes[2] = " + str(boxes[2].numpy()))

in yolo_eval(yolo_outputs, image_shape, max_boxes, score_threshold, iou_threshold)
31
32 # Use one of the functions you’ve implemented to perform Score-filtering with a threshold of score_threshold (≈1 line)
—> 33 scores, boxes, classes = yolo_filter_boxes(box_confidence, box_class_probs, boxes, threshold = score_threshold)
34
35 # Scale boxes back to original image shape.

in yolo_filter_boxes(boxes, box_confidence, box_class_probs, threshold)
24 # Step 1: Compute box scores
25 ##(≈ 1 line)
—> 26 box_scores = box_confidence * box_class_probs
27
28 # Step 2: Find the box_classes using the max box_scores, keep track of the corresponding score

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py in binary_op_wrapper(x, y)
1123 with ops.name_scope(None, op_name, [x, y]) as name:
1124 try:
→ 1125 return func(x, y, name=name)
1126 except (TypeError, ValueError) as e:
1127 # Even if dispatching the op failed, the RHS may be a tensor aware

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py in _mul_dispatch(x, y, name)
1455 return sparse_tensor.SparseTensor(y.indices, new_vals, y.dense_shape)
1456 else:
→ 1457 return multiply(x, y, name=name)
1458
1459

/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/math_ops.py in multiply(x, y, name)
507 “”"
508
→ 509 return gen_math_ops.mul(x, y, name)
510
511

/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_math_ops.py in mul(x, y, name)
6164 return _result
6165 except _core._NotOkStatusException as e:
→ 6166 _ops.raise_from_not_ok_status(e, name)
6167 except _core._FallbackException:
6168 pass

/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
6841 message = e.message + (" name: " + name if name is not None else “”)
6842 # pylint: disable=protected-access
→ 6843 six.raise_from(core._status_to_exception(e.code, message), None)
6844 # pylint: enable=protected-access
6845

/opt/conda/lib/python3.7/site-packages/six.py in raise_from(value, from_value)

InvalidArgumentError: Incompatible shapes: [19,19,5,80] vs. [19,19,5,4] [Op:Mul]

Thank you
Prejith

In yolo_eval(), the order of the arguments in this line is not correct.

1 Like

Thank you.

Prejith

In the future you might try searching on the error message. Seems like your trouble has been encountered before…

https://community.deeplearning.ai/search?q=InvalidArgumentError%3A%20Incompatible%20shapes%3A%20%5B19%2C19%2C5%2C80%5D%20vs.%20%5B19%2C19%2C5%2C4%5D%20%5BOp%3AMul%5D%20order%3Alatest

Some of those threads might have helped you

1 Like

Thank you. I will be careful next time. I’m just beginning to use the forums and I’m having some difficulty navigating to others’ solutions.

Regards
Prejith

Hey it’s fine to ask for help. Just wanted to remind that some of these exercises have a long history, and you might find exactly what you need with a targeted search. If not, even relating your question to a previous thread might help the community zero in on the problem and solution. Cheers

1 Like