Week 2 Residual networks: I get AssertionError: Wrong values when training=False:

{moderator edit - solution code removed}

i have same problem.

I don’t know how to resolve it. I have spent literally hours on it

I’ve solved it by replacing the X in X_shortcut with X_shortcut
{moderator edit - solution code removed}

1 Like

@Qihua I already had that step correctly implemented as you can see from the code above. So I don’t think it is the problem for me. Can you please share the entire convolutional_block? I have spent literally hours on this function

You have the kernel size and the strides backwards on the second component.

Also please note that it’s a violation of the Honor Code to publish your code in the first place and to ask someone else to publish theirs so that you can copy the answer.

I’m having the same issue and I did everything above, including triple checking to make sure the kernel size and strides match the directions given for each component in path. Any hints on what else I should check?

Sorry, but this whole assignment is basically a big exercise in careful proofreading. Are you sure that your batch normalization layers match the ones they show you in the template? The other key thing to check is that you have implemented the shortcut layers correctly. The inputs to the shortcut layers are different. The instructions aren’t very explicit, but the diagrams are the most clear expression of what is supposed to happen.

I got it working!. Thanks

I faced the same issue but resolved it finally

I’ve been working on this assignment to day and am stuck on convolutional_block function and the assertions failing. Please see attached. I’ve gone over my code multiple times and i’m pretty sure it’s correct, including using X_shortcut for the final block. I printed the function return value and it does indeed look wrong.

Anyway I can share my code with a mentor or somebody for some advice??

Many thanks

This whole assignment is an excruciating exercise in proofreading. Other common errors are not passing the training parameter to the BatchNorm or just to use the wrong kernel size or stride in any of the steps. It just takes one wrong character.

If those suggestions are not sufficient to get you there, check your DMs for a message from me.

Figured it out. When I run this notebook locally on my mac the assertion fails. I guess different CPU architectures spit out different values??? I’ve had this before on some previous labs. Run it on the coursera lab platform and worked fine. I knew there was nothing wrong with my code.

Interesting. Glad to hear that you figured it out. My guess would be that it’s more likely a “versionitis” problem than the CPU architecture difference. Everybody implements the IEEE 754 standard for floating point, so you should get the same results with the same code. So that suggests the code (meaning all the packages and libraries and yadda yadda) were different. The world of python packages and TF are pretty fluid. You can’t just install the latest versions of everything and assume it’s going to work in the same way. These notebooks were last revised in April of 2021, so a lot could have changed since then. You can try using Anaconda to duplicate the course environment. There are no official instructions, but here’s a thread with some pointers down that path …