Residual Network Programming Assignment - Float Assertion Error

Hi,

It seems like my test is failing due to rounding errors:

Output:

---> 40                                   [290.56854,  290.56854, 290.56854, 146.78427]]]), atol = 1e-5 ), "Wrong values with training=False"
     41

Actual:

[290.5685  290.5685  290.5685  146.78426]]]
96.85617

Error:
AssertionError: Wrong values with training=False

Function:
def identity_block(X, f, filters, training=True, initializer=random_uniform):

How do I go about that?

Note that the assertion checks more than just the last row of the output. It might be worth taking a close look at all the values vs the expected ones.

Yea, you are actually correct. The last matrix is also wrong. Not sure what us going on there

With training=False

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

 [[192.80818 192.80818 192.80818  96.90409]
  [ 96.90409  96.90409  96.90409  48.95204]]

 [[578.4246  578.4246  578.4246  290.71228]
  [290.71228 290.71228 290.71228 146.85614]]]
96.90409

With training=True

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

 [[1.      1.      1.      1.     ]
  [1.      1.      1.      1.     ]]

 [[8.67668 8.67668 8.67668 4.86576]
  [4.86576 4.86576 4.86576 3.     ]]]
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-26-eb060d3308af> in <module>
     22 print(np.around(A4.numpy()[:,(0,-1),:,:].mean(axis = 3), 5))
     23 
---> 24 public_tests.identity_block_test(identity_block)

/tf/W2A1/public_tests.py in identity_block_test(target)
     38                                   [ 96.85619,  96.85619,  96.85619,  48.9281 ]],
     39                                  [[578.1371,   578.1371,  578.1371,  290.56854],
---> 40                                   [290.56854,  290.56854, 290.56854, 146.78427]]]), atol = 1e-5 ), "Wrong values with training=False"
     41 
     42     np.random.seed(1)

AssertionError: Wrong values with training=False

Expected value

With training=False

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

 [[192.71234 192.71234 192.71234  96.85617]
  [ 96.85617  96.85617  96.85617  48.92808]]

 [[578.1371  578.1371  578.1371  290.5685 ]
  [290.5685  290.5685  290.5685  146.78426]]]
96.85617

With training=True

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

 [[0.40739 0.40739 0.40739 0.40739]
  [0.40739 0.40739 0.40739 0.40739]]

 [[4.99991 4.99991 4.99991 3.25948]
  [3.25948 3.25948 3.25948 2.40739]]]

Those are not rounding errors: they are real errors of some sort. There must be some respect in which your code differs from what they told you to do. Sorry, but this assignment is basically an excruciating exercise in proofreading. Time to get out your best glasses and have another careful look. :nerd_face:

I forgot to normalize one of the layers :slight_smile:

It’s great news that you were able to spot the mistake! Thanks for confirming.