Course4 week3 Shape incompatibility problem

All coding tests were passed in the assignment except the last one, which was provided by the course. I received an error message “Shapes (19, 19, 5) and (1, 19, 19, 5) are incompatible”. Please help. And how can I check the shape of different tensors in Predict?

And how can I check the shape of different tensors in Predict?

Predict() is a top level function, and several your previously implemented functions are called from here. For example, yolo_eval() is called from here. Then, yolo_filter_boxes() and some others are called from yolo_eval().
This error is most likely caused by one of your functions. So, you may want to check how the shape changes in there.

Thank you for your suggestion. I fixed an issue in yolo_filter_boxes() and it worked.

1 Like

As I review this assignment, I noticed that in yolo_model.summary(), the output layer is in the shape of (none, 19, 19, 425). But the text below says that the output shape is (m, 19, 19, 5, 85). I understand how to convert the (5, 85) into 425, but thought that the two are still different in shape and therefore a simple shape conversion is needed, right?

(none, 19, 19, 425) is an output from a neural network, called Darknet.

If you are interested in, you can see more in /yad2k/models/keras_yolo.py and keras_darknet19.py.

Please look at predict() in your notebook.

yolo_model_outputs = yolo_model(image_data)
yolo_outputs = yolo_head(yolo_model_outputs, anchors, len(class_names))   
out_scores, out_boxes, out_classes = yolo_eval(yolo_outputs, [image.size[1],  image.size[0]], 10, 0.3, 0.5)

Output from yolo_model, “yolo_model_outputs”, is passed to yolo_head(), which is in “keras_yolo.py”.
Then, yolo_head() handles output from the network, and summarizes output as combination of “bounding box size (4)”, “confidence (1)”, and “class probability (80)”. Now, you know how to handle those, and its shape. :slight_smile:

1 Like