COurse 4 week 2 exercise 3 Resnet 50

from outputs import ResNet50_summary

model = ResNet50(input_shape = (64, 64, 3), classes = 6)

comparator(summary(model), ResNet50_summary)

After running this cell , getting error

Test failed
Expected value

[‘Add’, (None, 15, 15, 256), 0]

does not match the input value:

[‘TensorFlowOpLayer’, [(None, 15, 15, 256)], 0]

AssertionError: Error in test

X = AveragePooling2D(pool_size=(2, 2))(X)
This is the avg pool I used.

This is my code

{moderator edit - solution code removed}

Hi, Rahul.

Hmmm, my code looks the same as yours as far as I can see from what you posted. My guess is that the error is not to do with the AveragePooling layer, but maybe something you did differently in either the identity block or the conv block. Are you sure your code passes all the “unit tests” there? Note that the “Add” block that it’s complaining about only happens in the “shortcut” layers of both the identity block and the conv block. That’s why I suspect something is wrong there, rather than in ResNet50, but that the unit tests aren’t catching it …

I Have passed all test cases before. I have checked my code many times.

This turns out to be a case in which the test failure is on ResNet50, but the bug it’s pointing to is actually in the identity_block routine. Notice that it’s telling you that it didn’t like the “Add” layer there. Check to make sure that you followed the directions in which they specifically said to use the “Add()” function. They also give you a worked example of how to do this in the template code for the convolutional_block function.

1 Like

Hi Paul,
Thank you very much for your kind support. I have solved the error. I would like to connect with you on LinkedIn also. It would be great if you share your Linkedin profile.

Thank you
Rahul

1 Like

Hi Paul,

I have checked my code many times, but still got the error message

Test failed
Expected value

[‘Conv2D’, (None, 2, 2, 512), 524800, ‘valid’, ‘linear’, ‘GlorotUniform’]

does not match the input value:

[‘Conv2D’, (None, 2, 2, 256), 262400, ‘valid’, ‘linear’, ‘GlorotUniform’]

AssertionError Traceback (most recent call last)
in
3 model = ResNet50(input_shape = (64, 64, 3), classes = 6)
4
----> 5 comparator(summary(model), ResNet50_summary)

/tf/W2A1/test_utils.py in comparator(learner, instructor)
21 “\n\n does not match the input value: \n\n”,
22 colored(f"{a}", “red”))
—> 23 raise AssertionError(“Error in test”)
24 print(colored(“All tests passed!”, “green”))
25

AssertionError: Error in test

Here is my code:

{Moderator edit - solution code removed. Please see Course Honor Code.}

I couldn’t figure out what are the problems. Please help! Thank you very much!

Hi, Zhou.

This is an exercise in proofreading and I guess checking “many times” is not quite enough. Your filters are not the same as the instructions ask for in Stage 5 on the convolutional block.

Regards,
Paul

1 Like

Hi Paul,

I solved the problems.

Thank you very much for your help!

Best regards,
Zhuo

Hi @paulinpaloalto
I get error as:
Test failed
Expected value

[‘Conv2D’, (None, 8, 8, 512), 66048, ‘valid’, ‘linear’, ‘GlorotUniform’]

does not match the input value:

[‘Conv2D’, (None, 8, 8, 512), 131584, ‘valid’, ‘linear’, ‘GlorotUniform’]

AssertionError Traceback (most recent call last)
in
3 model = ResNet50(input_shape = (64, 64, 3), classes = 6)
4
----> 5 comparator(summary(model), ResNet50_summary)

/tf/W2A1/test_utils.py in comparator(learner, instructor)
21 “\n\n does not match the input value: \n\n”,
22 colored(f"{a}", “red”))
—> 23 raise AssertionError(“Error in test”)
24 print(colored(“All tests passed!”, “green”))
25

AssertionError: Error in test

My code is:

{moderator edit - solution code removed}

Could you please advise?

Hi @Rahulphysicsmishra , wondering how you fixed your error? I might have the same type of error as the one you had before.

The problem was in the first graded exercise. Follow instructions there properly because although you have passed test but it has one mistake in it.

1 Like

Thanks @Rahulphysicsmishra
I did double checked the first exercise too. Have no clue on what could be wrong!

Here you can see my first exercise code:

{moderator edit - solution code removed}

me too please help???

@Murat_Hamarat Are you sure you have carefully checked the parameters on all your added layers against the instructions? This whole assignment is an excruciating exercise in proofreading.

now i did it but score is 0/100

what should i do

Thanks! I had the same issue and could solve it. I had used X+X_shortcut instead of the adding function.

Hi Paul,
Thank you so much for your support on this. I made a similar mistake in identity_block of using+ instead of Add function, and the test is passed so I didn’t realized the mistake until I saw your response. Thanks!

I had the same bug as do many people in this post:


I have checked countless times about my previous implementation. I passed all the tests for the previous 2 functions, and I used the Add function as well, but still, I’m getting this error message.

Are you sure that all your implementations of Add() use that code instead of a more generic implementation? The error message is pretty specific. If you check carefully, you should be able to map that to exactly which layer it is. Look at the “summary” output and find that layer.

The other thing to realize is that just typing new code and then calling the cell again does nothing: it runs the old code again. You actually have to click “Shift-Enter” on the changed cell in order for the new code to get interpreted into the runtime JIT image. Or doing “Kernel → Restart and Clear Output” followed by “Cell → Run All” will do it.

Note that the bug is not in the resnet50 routine: it’s in either identity_block or convolutional_block, because that is where the Add() operations are for the shortcut layers. Follow the first part of this thread: it sounds like your mistake is the same as Rahul’s.