Help! Residual conv network Programming Assignment

I submitted my programming assignment and it gives me one error, I am not sure what am I doing wrong there, can anyone help me with this,


And here is my implementation,

{moderator edit - solution code removed}

There are no direct “Add” operations in ResNet50, so the problem must be in either your identity block or your conv block functions. You must have specified the addition operation using an operator like “+” instead of actually using the Add layer function. They gave you explicit instructions about how to do that. Please go back and check those two functions and read the instructions for them again.

1 Like

Yes, I did the experiment of using “+” instead of the Add() layer in the identity block to add the X and X_shortcut and I get exactly the error that you show.

Actually now that I go back and look again, I had forgotten that they give you the code in the convolutional_block function to do the add of X and X_shortcut, so your problem must be in the identity block. You can use the code in conv block for the same function in the identity block.

1 Like

Aah! Thanks for correcting me, I used the hint given Add()([X, X_shortcut]) and it worked. Thanks again.

It’s good to hear that you were able to pass all the tests.

It might also be worth saying that your previous code was not really incorrect from a functional standpoint, which is why your code passed the tests for the identity block function. The numeric output is correct. It’s just that they chose to write the tests for the ResNet50 model to use essentially a text comparison of the definitions of all the layers. That forces you to use exactly the same functions that they used in order for your model to match theirs. Using a different function, even if it is equivalent, will not pass the tests as they are written here.

1 Like

Hi Paul, I do use “Add” in the “identity_block”, but still got the “TF0pLambda” issue. Can I ask why?

That probably just means you didn’t hit “Shift-Enter” on the actual function cell to recompile the new code. Or try “Kernel → Restart and Clear Output” followed by “Cell → Run All” and see if it still fails.

Here’s a thread that is a more complete description of the “old code” problem.

I restarted the Kernel, and use “cell” - “Run all above” and that test cell, still got the “TF0pLambda” issue

Ok, please show us the complete exception trace that includes that error.

here it is

Well, Add appears in two places, right? In the identity_block and in the conv_block. In the conv_block the code was given to you, but you need to write it in the identity_block case. If I use “+” in the identity_block case, I get the error you show but it’s on the (15,15, 64) input.

I did not change the “def convolutional_block”, i.e. “X = Add()([X, X_shortcut])
X = Activation(‘relu’)(X)”

Actually I get the error on the (15,15,256) case if I fix identity_block and then rerun ResNet50 and the test.

When you restarted the kernel, are you sure you did the “Restart and Clear Output” option?

Yes, I do, can I temporarily upload my Jupyternotebook here?

Let’s do it by DM. I will send you a DM and you can reply.

Just to close the loop on the public thread here, the problem was that there was a “+” used, but it was in the arguments to the Add() function. :nerd_face: