C4W2 Resnets: convolutional block code not working

The following code is giving me this error

=> AssertionError Traceback (most recent call last)
in
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])
16

AssertionError: Wrong values when training=False.

1 Like

You have misinterpreted what is supposed to happen in the “shortcut” path. You have the input as “X” in both steps there. That is not what was intended. They don’t really spell it out in the instructions, but have a look at the diagram that shows how the “skip” connection is intended to work.

1 Like

Also please do us a favor and remove the solution source code from your initial post once you have this debugged. It definitely helps to see the source code for debugging purposes, but the goal is not to leave the source code sitting around in the forums. Thanks!

Thanks! I will take it down now.

1 Like

hello i am getting the same error .
how should i pass this training parameter ?
can we do this at batchnormalization layer?
but it’s not in the keras Docs!
help me out!!
thankyou

@samida: They give you examples in the template code of what the BatchNorm layers look like. The ones you add should look exactly the same.

Also please check your “shortcut” layers to make sure you use the correct inputs there. That was the error discussed earlier on this thread.

Dear @paulinpaloalto, I have the same issue, but I set the inputs correctly, X_shortcut when needed, X otherwise in the main path. training is set equal to the training argument in all batchnormalizations. Nevertheless, I still get an error, could you help me understand why?

Hi, @simonegiancola09. Do you get a “shape mismatch” error or do you just get different output values? If the former, then the thing to do is to check all your filter and stride parameters carefully.

I get the latter error. Moreover, the next cells test on a Xtest Ytest pair that is not loaded, as well as a model function (no capital at the beginning) that if I remember correctly is not defined.

@paulinpaloalto tagging you as I forgot

I’m not sure I understand what you mean about “not defined”. That can mean you misspelled something or it can be something simple like forgetting to actually run all the previous cells in the notebook. Try “Cell → Run All Above” and see if that helps.