Completely lost on programming assignment #1 (week2 CNN)

I have been able to get other things working, but after several hours, I am a little lost.



GRADED FUNCTION: convolutional_block

I copied in the kernal sizes and strides from the example above, and am getting this error.

AssertionError Traceback (most recent call last)
12 assert type(A) == EagerTensor, “Use only tensorflow and keras functions”
13 assert tuple(tf.shape(A).numpy()) == (3, 2, 2, 6), “Wrong shape.”
—> 14 assert np.allclose(A.numpy(), convolutional_block_output1), “Wrong values when training=False.”
15 print(A[0])

AssertionError: Wrong values when training=False.

I know I can’t copy my code, but from what I understand, I did the parts right above it, and I can’t figure out what I am doing wrong. Is there a way to share part of my code without breaking the rules?

I am having the same issue with



Where I feel like I edited the command lines, but am getting this error
Perhaps with this one, the error will be more obvious

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

/tf/W2A1/ in comparator(learner, instructor)
14 def comparator(learner, instructor):
15 if len(learner) != len(instructor):
—> 16 raise AssertionError(f’Models does not have the same number of layers {len(learner)} != {len(instructor)}’)
17 for a, b in zip(learner, instructor):
18 if tuple(a) != tuple(b):

AssertionError: Models does not have the same number of layers 173 != 177

Any hints would be great - I’ve been stuck on these two for hours (I actually went and finished the assignment after this one and came back and am still stuck)


For the second error in which you end up with a different number of layers, it should be pretty clear how to debug that. They show you how to print all the layers and compare them. So where are your missing layers?

For the first error, that’s a bit trickier, but this whole assignment is basicallly a huge exercise in proofreading: they tell you what to do and you need to make sure you’ve followed the instructions as carefully as you can. Given that your error is in the training = False case, which is the first of the two cases, the error must be in the basic structure. One common error is not to use the correct input values for the “shortcut” section. They don’t explain that very carefully in words, but the diagrams are the clearest indication of how the shortcut layers should work. Please compare your code to the diagrams.

Thanks. With fresh eyes, I found the typo for the shortcut error (it was right in one place and not the other). Strangely the second error (number or layers) magically disappeared and it ran perfectly this morning with no changes

That’s great that you were able to spot the error! The number of layers issue could have been caused by the shortcut problem. If you had the inputs wrong, that changes the “compute graph”, right? The whole point here is that it’s no long a simply connected graph.