Course 4 week 2 assignment 1 exercise 1 identity block

Hi, I have submitted week 2 assignment 1, and my grade was 100/100. However, when I downloaded the code and then ran the code on my pc, I receive the following error which is related to the identity block:


AssertionError Traceback (most recent call last)
in
26 print(np.around(A4.numpy()[:,(0,-1),:,:].mean(axis = 3), 5))
27
—> 28 public_tests.identity_block_test(identity_block)

~\OneDrive - ------\Course\deepLearning AndrewNg\C4\W2A1-Residual Networks\public_tests.py in identity_block_test(target)
35 assert resume[1, 1, 0] - np.floor(resume[1, 1, 0]) > 0.7, “Looks like the BatchNormalization units are not working”
36
—> 37 assert np.allclose(resume,
38 np.array([[[ 0., 0., 0., 0., ],
39 [ 0., 0., 0., 0., ]],

AssertionError: Wrong values with training=False

and my code is as follows:

{Moderator edit: Code Removed}

I really appreciate it if anyone can guide me to solve this issue.

Many thanks!

Hello,

I deleted your code as it is against the community guide. In the future, please do not post your code.

Regarding your query, maybe your PC has a different version of Python, TensorFlow, and other libraries from the Coursera environment. Coursera use:

Python 3.8.10
TensorFlow 2.9.1

You can check yours by below code:

!python --version
import tensorflow as tf
print(f"TensorFlow {tf.__version__}")

BTW, on Google Colab, I can run this assignment with Python 3.10.11, TensorFlow 2.12.0

Best,
Saif.

Hello Saif,

Thank you very much for your reply and tips.
You are correct, the issue was related to Python and TensorFlow versions on my device.

Best regards,
Fatemeh

You may want to read this guide for virtual environment in your PC. Well, it is a little bit tricky, so, read Colab guide if you want to use it.