Course 3 - Week 2 - Zombie assignment


First, your Exercise 6.1 is fine. Your list of variables does include the two mentioned, (_base_tower_layers_for_heads and _box_prediction_head), although the data shown in the Expected Output seems to be out-of-date now. _box_prediction_head is the same, but base_tower_layers_for_heads is stored slightly differently now, although you can see that the main data is the same - the dictionary, {'box_encodings': ListWrapper([]), 'class_predictions_with_background': ListWrapper([])}. I tried running my old code for this exercise and my variables look like yours now, but it still runs fine for Exercise 9.1. I’ll post a request to the developers to update the “Expected Output” for this part so others aren’t thrown off by it.

Your problem in Exercise 9.1 is a mystery. A couple of things I noticed:

  • The shapes in the error [2] and [91] look familiar: 2 = num_classes+1 for our new Zombie model, and 91 = num_classes+1 for the original RetinaNet model we started from
  • You are not the first to see this problem, see this post: ValueError: Unequal shapes [2], [91]

I suspect the +1 is for an extra class for “background” used internally by the model as hinted by this comment in section 9.1:

        3) class_predictions_with_background: 3-D float tensor of shape
          [batch_size, num_anchors, num_classes+1] containing class predictions

It seems like somehow you have something that is using the new # of classes, but something else left behind that is still using the old # of classes and they are clashing when you call detection_model.loss(), but I don’t have a great guess where the issue is.

My strongest suspicion is that your code is right, but that there is some cell that you accidentally didn’t run which led to the old # of classes being left in place somewhere. This would be consistent with the lack of info about a solution in the other posting about this problem, as well as the comment from the mentor that the student’s code worked fine when the mentor tried it. So… my first suggestion is to try loading your assignment again and carefully re-run the cells in order (skipping the “Option 1” cells in Exercise 2) and see if that works for you.

If it still doesn’t work, you can try printing prediction_dict['class_predictions_with_background'].shape before calling detection_model.loss() in Exercise 9 to make sure the last parameter is 2 (for num_classes + 1). Then poke around to see if you can find anywhere else you notice in your code where the old class prediction layers or num_classes might have been left in the model somehow.

I’ll also ask on the other thread to see if anyone else ever figured this out.

If you’re still stuck after checking these things, feel free to DM me a copy of your .ipynb and I’ll see what I can find