Course 4 Week 3 Assignment 1 Exercise 1 YOLO filter boxes

{moderator edit - solution code removed}

I can’t figure out what I should do in this exercise. I am not familiar with tensorflow and since the course itself doesn’t involve any tensorflow related thing in the lectures, I struggle with these assignments though I read the documentations linked in the assignment (I assume I lack preliminary information to truly understand them) I would like to hear your suggestions.

I think your approach is right. You just need to think two things as follows.

  • Please double check the meanings of each variables and how those are related with. Some of your implementations are logically incorrect.
  • Please read hints and inline guidance carefully. Those are quite important, and help you to implement the code.

For example, if you look at the Step 4, an inline guidance says.

Step 4: Apply the mask to box_class_scores, boxes and box_classes (≈ 3 lines)

scores, boxes, and classes are corresponding to "box_class_scores", "boxes", and "box_classes" respectedly. What we need to do is to apply a mask for those.
Then, if we look at your implementation, you will see that your 1st and 3rd line are not correct.

For the Step 2, If you look at the guidance it says as follows.

  • the index of the class with the maximum box score
  • the corresponding box score

The first one is to get the index. So, using “argmax” is correct.
The second one is to get actual scores. If “box_scores” is a simple vector or list, you can easily get with the index. But, it is 4D Tensor. Then, if you go back to “useful hints”, you can find “tf.math.reduce_max” seems to be useful. That’s the right one to use for getting “box_class_scores”. You need to revisit this line.

Hope this helps.

By the way, posting your code in here is not recommended. Please remove those.
We can start with a Traceback, and discuss the problems.


Nobu has well covered the specifics of this function. On the more general question of TensorFlow, it has been introduced in these courses and discussed quite a bit. The first mention and the real introduction is in Week 3 of DLS Course 2. If you skipped Course 2 and came directly to Course 4, you might want to watch the lectures from C2 W3 about TF. You can do that in “audit” mode, so it wouldn’t cost you anything. But in “audit” mode, you’d miss the assignment that includes the specific introductory examples. There are also more TF/Keras examples in the assignments in the first week of this course (DLS C4).

There are lots of tutorials on the TensorFlow site as well.

1 Like