C4_W2_A1 Assignment error

When I test the identity_block assignment in W2A1, I get below error Wrong Values with Training - true

I checked the filter passed and other places, doesn’t seem to find the issue.

Please help

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
c:\CNN\Assignments\W2A1\Residual_Networks.ipynb Cell 12 line 3
     26 A4 = identity_block(X, f=2, filters=[3, 3, 3],
     27                    initializer=lambda seed=0:constant(value=1))
     28 print(np.around(A4.numpy()[:,(0,-1),:,:].mean(axis = 3), 5))
---> 30 public_tests.identity_block_test(identity_block)

File c:\CNN\Assignments\W2A1\public_tests.py:56, in identity_block_test(target)
     54 A4np = A4.numpy()
     55 resume = A4np[:,(0,-1),:,:].mean(axis = 3)
---> 56 assert np.allclose(resume, 
     57                      np.array([[[0.,         0.,         0.,         0.,        ],
     58                               [0.,         0.,         0.,         0.,        ]],
     59                              [[0.37390518, 0.37390518, 0.37390518, 0.37390518],
     60                               [0.37390518, 0.37390518, 0.37390518, 0.37390518]],
     61                              [[3.2380054,  4.1391973,  4.1391973,  3.2380054 ],
     62                               [3.2380054,  4.1391973,  4.1391973,  3.2380054 ]]]),
     63                    atol = 1e-5 ), "Wrong values with training=True"
     65 print(colored("All tests passed!", "green"))

AssertionError: Wrong values with training=True

That’s an unexpected error, because the identity_block() function does not use a training parameter.

Are you using the latest copy of the notebook? It was updated about a month ago.

I have downloaded notebook today. It is latest I believe

What do you mean by “downloaded”? You don’t need to download any files. You should work on the notebooks in the Coursera Labs environment.

Even on the Coursera lab environment I get same error. Can you please send me version which works for you.

With training=False

[[[   0.         0.         0.         0.     ]
  [   0.         0.         0.         0.     ]]

 [[ 768.9997   768.9997   768.9997   384.99985]
  [ 384.99985  384.99985  384.99985  192.99992]]

 [[2306.999   2306.999   2306.999   1154.9995 ]
  [1154.9995  1154.9995  1154.9995   578.99976]]]
384.99985

With training=True

[[[0.      0.      0.      0.     ]
  [0.      0.      0.      0.     ]]

 [[0.40732 0.40732 0.40732 0.40732]
  [0.40732 0.40732 0.40732 0.40732]]

 [[5.00011 5.00011 5.00011 3.25955]
  [3.25955 3.25955 3.25955 2.40732]]]

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Input In [5], in <cell line: 30>()
     26 A4 = identity_block(X, f=2, filters=[3, 3, 3],
     27                    initializer=lambda seed=0:constant(value=1))
     28 print(np.around(A4.numpy()[:,(0,-1),:,:].mean(axis = 3), 5))
---> 30 public_tests.identity_block_test(identity_block)

File /tf/W2A1/public_tests.py:38, in identity_block_test(target)
     34 assert np.floor(resume[1, 1, 0]) == 2 * np.floor(resume[1, 1, 3]), "Check the padding and strides"
     36 assert resume[1, 1, 0] - np.floor(resume[1, 1, 0]) > 0.7, "Looks like the BatchNormalization units are not working"
---> 38 assert np.allclose(resume, 
     39                    np.array([[[  0.,        0.,        0.,        0.,     ],
     40                               [  0.,        0.,       0.,        0.,     ]],
     41                              [[192.99992, 192.99992, 192.99992,  96.99996],
     42                               [ 96.99996,  96.99996,  96.99996,  48.99998]],
     43                              [[578.99976, 578.99976, 578.99976, 290.99988],
     44                               [290.99988, 290.99988, 290.99988, 146.99994]]]), 
     45                    atol = 1e-5 ), "Wrong values with training=False"
     47 tf.keras.backend.set_learning_phase(True)
     48 np.random.seed(1)

AssertionError: Wrong values with training=False

Use the current version from Coursera Labs.

Ok got it. Looks like I had an additional component in my code.
Thank you for your reply.