Assignment 1 week 2 coarse 4 - Wrong values when training=False message

I’m working on assignment 1 week 2 coarse 4. I am building the convolutional ResNet block. I looked at the commentary in the function. There it says the function must return a tensor of shape (n_H, n_W, n_C). However, once I run my skip-connection with convolution, my function returns (m, n_H, n_W, n_C).
There is an assert statement that checks for output dimensions from the function: assert tuple(tf.shape(A).numpy()) == (3, 2, 2, 6), “Wrong shape.” I pass this test. Is there a typo in the function commentary?
I keep getting the Wrong values when training=False message. I’ve double checked all the TF functions calls, the parameters are correct. I’ve followed the coding template provided, yet I can’t see what the issue is.
Please can you assist.

Thanks for reporting. I’ve notified the staff to fix the documentation bug. The return value should have shape (m, n_H, n_W, n_C).

If you are running this notebook in coursera environment and are not hardcoding all parameters, please click my name and message your notebook as an attachment.

@Matt_Gerhold Thanks for the notebook.
Your implementation of the shortcut component is incorrect. Please fix this section:
##### SHORTCUT PATH ##### (≈2 lines)

The notebook seems corrupt as well. Please get the latest version from Help > get latest version of the lab and fill in your existing code if you don’t pass the tests.


Are you using Corsera platform or your local environment ?

If your TF code is correct, there are two possibilities. One is the seed for random number generator, and other is “initializer”, in this case, GlorotUniform for convolutional_block(). (You see “random_unitform” is used as a default initializer for identity_block(), but “glorot_uniform” is used for convolutional_block().

Can you check which “glorotUnform” is used for you initialization ?
In the Corsera platform, it is


But if other combination of Python and Tensorflow version, it may import


It looks like even if we set the same seed (=0), result seems to be different.

The problem is this assignment refers a fixed output, convolutional_block_output1. This is not dynamically calculated on the fly, but is a given data, which was calculated in their environment.
So, if we are not using exactly same environment, then, results are different which cause assertion errors.

<It looks like the big assumption of “If your TF code is correct” was not correct based on Balaji’s note. But, I will keep this in the case of someone falls into this problem.

1 Like

Thanks balaji, I see it now. :laughing:

Thanks. I was losing my head over this only to realize it’s the difference in environment. To fix this in local environment, import glorot_uniform as follows:
from tensorflow.python.keras.initializers.initializers_v2 import GlorotUniform as glorot_uniform