AssertionError: Wrong values when "onvolutional Block" Exercise

in the assignement1 in week2
I have this error “AssertionError: Wrong values when training=False.” when implement “Convolutional Block” exercise
and I am sure that the input of shortcut path is correct,
but I guess that the error is resulted by the random initialization seed for the kernels, although I have written the code as it is written in the template, and make the seed 0 for initializer for all the convolutional layers,

but I guess that the error is resulted by the seed because I get different value for A in each time I execute the following code:
from outputs import convolutional_block_output1, convolutional_block_output2


#X = np.random.randn(3, 4, 4, 6).astype(np.float32)

X1 = np.ones((1, 4, 4, 3)) * -1

X2 = np.ones((1, 4, 4, 3)) * 1

X3 = np.ones((1, 4, 4, 3)) * 3

X = np.concatenate((X1, X2, X3), axis = 0).astype(np.float32)

A = convolutional_block(X, f = 2, filters = [2, 4, 6], training=False)

assert type(A) == EagerTensor, “Use only tensorflow and keras functions”

assert tuple(tf.shape(A).numpy()) == (3, 2, 2, 6), “Wrong shape.”

assert np.allclose(A.numpy(), convolutional_block_output1), “Wrong values when training=False.”


can any one help me please

Welcome to the community !

One question is, are you using your local environment ?
If so, depending to the version of Python/Keras, behavior of “glorot_uniform” is different.

If that’s the case, try this. (But, of course, you need to be very careful for a grader submission.)

from tensorflow.python.keras.initializers.initializers_v2 import GlorotUniform as glorot_uniform

in stead of

from tensorflow.keras.initializers import glorot_uniform

Of course, the above is assuming that you properly set “training=…” for BatchNorm.

Thanks you MS. Asai
for your question, No, I use google colab,
but I used this statement that you gave me “from tensorflow.python.keras.initializers.initializers_v2 import GlorotUniform as glorot_uniform”
and now, I get the same value for A in each time I execute the previous code, but I still get the previous error despite of getting the same expected output like the following:

Thank you Ms.Asai,
alhamdulillah, I solved this problem, the problem was in the third convolutional layer I set the stride to s instead of 1 by mistake, I solved it now