Code error - Course 4, week 3, assignment 1, part 4

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

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

in yolo_filter_boxes(boxes, box_confidence, box_class_probs, threshold)
25 ##(β 1 line)
26 # box_scores = None
β> 27 box_scores = box_confidence * box_class_probs
28 # Step 2: Find the box_classes using the max box_scores, keep track of the corresponding score
29 ##(β 2 lines)

/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,2] vs. [19,19,5,80] [Op:Mul]

If you are trying to just copy over your solution from this assignment in the old course, you have to be super careful: they changed the order of arguments in yolo_outputs and the arguments to yolo_filter_boxes. If itβs any comfort, the reason I am familiar with this issue is that I stepped on the very same landmine β¦

If that turns out not to be the reason in your case, then you just have to track backwards. The exception trace shows you which variables donβt match and what their dimensions are. So which one is wrong and where did it come from?

3 Likes

many thanks, I found the problem.

2 Likes

Hi, Iβm stuck on the same issue. Could you please let me know what youβve changed to solve the error?

Never mind! I got it. Thanks a lot @paulinpaloalto

1 Like