C4_W2 ResNet50 implementation model summary error

Hi, I am facing a test failed error in programming assignment of week 2 of Convolutional neural network course in which the Model summary of my model isi shown as
[‘TFOpLambda’, (None, 15, 15, 256), 0]
while the expected is :
[‘Add’, (None, 15, 15, 256), 0]
how to rectify this error as the grader shows incorrect implementation of the ResNet50 model

Link to the classroom item I am referring to : Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera

1 Like

Did you use a “lambda” function in the notebook?
If so, don’t do that.

1 Like

There is a cell marked as “you can not edit this cell” which uses initilizer as lambda in identity block

1 Like

But that’s in the block testing cell and there isn’t any use of lambda function elsewhere

1 Like

Can you post an image of the entire model summary?

Got it. After looking at the complete summary i realized that in the identity block instead of using the Add() function, i had simply used the ‘+’ operator. Thanks for the help :+1:t2: .


Yes, the two operations are equivalent, but the way the tests work here is that they do a literal compare of the “summary” output, so you have to use the exact function that they tell you to use in the instructions. Just being logically correct isn’t good enough. :laughing:

But they did their best to help you out here by being very explicit in the instructions about how to implement that logic.

1 Like

But one thing that’s bugging me is upon using ‘+’ operator the accuracy of the model upon training is 0.7666666507720947 while using Add() function gives accuracy of 0.7083333134651184. I’ve tried it more than once but same results.

1 Like

When doing this sort of testing, be sure you “restart the kernel and clear all the output” every time you start a test.


Also note that even if you use Tom’s method to always start from the same state, the results still are not deterministic even if you don’t change the code. I ran it three times from the “reset” state with the Add() implementation and got three different values for the Test Accuracy:

  1. 0.85
  2. 0.866666
  3. 0.766666

Even when you set the random seeds for the PRNG algorithms, the results are still not deterministic, because the training is parallelized across multiple CPUs and GPUs. Parallelism is inherently non-deterministic, since exactly how the threads get scheduled depends on everything ele that’s happening on the computer at the same time. There are ways to artificially constrain that to be deterministic, but then you lose most of the advantages of parallelization and it really costs you in terms of performance. Here’s a thread from mentor Raymond which discusses this point in a lot more detail.