Trouble Implementing Convolutional Blocks and ResNet50 Model for Week 2 Programming Assignment

Hello everyone,

I’m currently working on the first programming assignment for Week 2, focused on Residual Networks, and I’ve encountered some challenges with implementing the convolutional_block function and the ResNet50 model correctly. This task is part of the Deep Learning specialization, specifically in the course about convolutional neural networks.

Here are the key points I’m struggling with:

  • Properly setting up the convolutional_block to adjust input and output dimensions when they do not match.
  • Structuring the ResNet50 function to include the necessary convolutional and identity blocks across different stages as specified in the assignment description.

I’ve followed the instructions to implement the necessary components for the ResNet architecture, ensuring to use the correct filter sizes, strides, and initializers. However, I’m facing issues with indentation errors and possibly incorrect implementations leading to unexpected output dimensions or model performance.

My grader gave me the following message:
Code Cell UNQ_C1: Function ‘identity_block’ is correct.
Code Cell UNQ_C2: Function ‘convolutional_block’ is incorrect. Check implementation.
Code Cell UNQ_C3: Function ‘ResNet50’ is incorrect. Check implementation.
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.

I’ll share the picture off the code below

{mentor edit: code removed}

1 Like

Please don’t post your code on the forum. That’s not allowed by the Code of Conduct. If a mentor needs to see your code, we’ll contact you with instructions.

What errors do you get when you run the notebook? Please post a screen capture image - not your code.

Some observations:
In X_shortcut, try “filters = F3” and “strides = (1, 1)” instead of just F3 and (1, 1). Positional arguments can be tricky. Might help, or might not.

In AveragePooling2D(), try removing all of the positional arguments there.

1 Like

Ok, sorry about that.
I thought that since the code was wrong it wouldn’t be a problem to post it.

I’ll try your recomendations and soon be back with the feedback,
Thanks a lot

1 Like

Still having some trouble

first, in the convolutional_block

and in the Resnet 50

1 Like

sorry, the secon is the same as the first

1 Like

Since ResNet50 calls convolutional_block, the right strategy is to concentrate on solving the problem in the earlier function first. This whole assignment is basically an excruciating exercise in proof-reading: there are lots of details for how the various layers are constructed and you have to get all of them right. Of course you could argue that’s not anything new, because programming is always nitpicking at that level: a single wrong character can ruin everything.

Are the most recent results you are showing after you made the changes that Tom suggested? If so, then please take one more careful look through the instructions for convolutional_block and compare what they say to your code.

And you’re scaring me with that statement. Indentation is a fundamental part of the syntax in python and you had better be very clear about how it works. There aren’t a lot of nested constructs in convolutional_block though, so it should be pretty straightforward in this instance.

If these suggestions aren’t enough to get you to a viable solution, then we’ll probably need to look at your code. As Tom said, we can’t do that on a public thread, but we can use DMs for that. Let me know if you still need more help after all that I said above and we’ll graduate to the source code level.

I’m sorry, I really didn’t mean to say “Indentation erros” since I know that’s a basic concept, I wanted to say “Implemetation error” but was distracted. I’m a Brasilian Physician and, still after some studying I still have some problems with programming terminology, specialy in english.

However, after folowing TMosh’s advice I was able to correctly run the convolutional_block function and make a 100/100, thank you so much.

1 Like

Hi, André.

That’s great news that you were able to solve the problem with convolutional_block. Onward!

Regards,
Paul