Exercise 3 - ResNet50. Test Failed

Hello!

While testing ResNet50() function I get the following error:

The same issue was mentioned in the thread Exercise 3 - ResNet50. AssertionError: Error in test - week 2 (Assignment 1)

The advice given by the mentor in this thread was to check the convolutional_block function. I have “All tests passed” for my convolutional_block() function.

What could be the issue?

Thanks!

Hi Veronika!

This usually indicates that there might be something wrong with the number of filters, the kernel size, or the strides in one of your Conv2D layers, especially in a conv_block where the dimensions are changed. Since you mentioned that you passed the test for the convolutional_block function, the problem may lie in how the identity_block or the overall structure of the ResNet50 model is defined. To narrow it down further, you can double check:

  • If there are inconsistencies in the shapes passed between layers in the ResNet50 function.
  • If the blocks in the model (identity and conv) follow the architecture as expected.

Try to look closely at the implementation of your ResNet50 function, especially where the blocks are connected, to ensure the parameter sizes match the expected architecture.

Hope this helps!

1 Like

If your identity block and conv block functions passed their tests, then the problem is most likely in your resnet50 logic and how you call the earlier functions. The model being created here is pretty complex, but you can actually compare the full “summary” output of your model versus the “expected” output to see where that first mismatch occurs. Based on that, then you can track that back to where in the logic the error must be.

The other point to notice is that the output shape you get is correct, but what differs is the number of trainable parameters in that conv layer. So one possibility would be a layer with “same” padding and stride of 1, but with the wrong f filter size. If that extra clue adds any value …

1 Like

Hello @nadtriana and @paulinpaloalto ,

Thank you for your advices.

I double-checked all the stages of the code in Exercise 3 - ResNet50 for misspellings, typos, the order of arguments, alignment with instructions, etc.

Everything was correct.

I also reviewed the answers for similar issues in the community one more time and found a thread that helped me identify the root of the problem Course 4 week 2 exercise 3 ResNet50 - error in test

Despite the notification that “All tests passed,” the issue was caused by an error in the previous exercise (Exercise 2 - convolutional_block). I didn’t follow the correct order mentioned in the code comments for the Final Step of Exercise 2.

Thanks again for your help.

2 Likes

That’s great to hear that you found the solution. But note that if you are talking about the addition step there, the correct code was just given to you in the template and did not require any modification. The comment associated with those lines is also explicit about the order. Of course addition is commutative, so you would think the order doesn’t matter, but changing the order changes the compute graph and the test for resnet50 is doing a literal comparison between the two computation graphs as its check.

1 Like

“addition is commutative, so you would think the order doesn’t matter, but changing the order changes the compute graph and the test for resnet50 is doing a literal comparison between the two computation graphs as its check.”

Yes, I see now :slight_smile:

1 Like