Course 2 Assignment 3 Exercise 5 - Forward Propagation Error

Hi, I don’t think my code has any problems, but it shows an error message of “Output does not match”. Please look into the attachment for further details. Thank you so much for your time and help.

[code removed - moderator]


The code in your post is correct. Please click my name and message your notebook as an attachment. I want to confirm if any other cell has changed.

If you are using a tensorflow version other than 2.3 you will get wrong values.

e.g. using tensorflow version 2.8 I get:

tf.Tensor(
[[-1.6990757  -1.8013326 ]
 [ 0.6480478   0.599451  ]
 [ 1.0591697   0.6126361 ]
 [-1.448843   -1.3232949 ]
 [-0.6428431  -1.0289742 ]
 [ 1.4259917   0.86040926]], shape=(6, 2), dtype=float32)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
C:\Users\JAIMEG~1\AppData\Local\Temp/ipykernel_45712/4289173325.py in <module>
     18     print("\033[92mAll test passed")
     19 
---> 20 forward_propagation_test(forward_propagation, new_train)

C:\Users\JAIMEG~1\AppData\Local\Temp/ipykernel_45712/4289173325.py in forward_propagation_test(target, examples)
      6         assert type(forward_pass) == EagerTensor, "Your output is not a tensor"
      7         assert forward_pass.shape == (6, 2), "Last layer must use W3 and b3"
----> 8         assert np.allclose(forward_pass, 
      9                             [[-0.13430887,  0.14086473],
     10                              [ 0.21588647, -0.02582335],

AssertionError: Output does not match

but using tensorflow version 2.3 (preinstalled in coursera notebook provided ) I get the correct answer with all tests passed

Thanks for the notebook, @m4nual. Please execute your notebook in coursera environment for correct results. Your code for random_mini_batches passes the tests.
If you want to try things out on non-coursera environment, I recommend you ensure that dependencies are accounted for.
coursera runs numpy version 1.18.4.

For instance, you could do the following:

import numpy as np
print(np.__version__)

Got it. Thank you so much.

Hi @m4nual

Please click ‘solution’ on the appropriate post and ‘like’ any posts that have been useful so that future learners with your same issue know it has been solved and get quick access to the most important information

Welcome to the community :slight_smile: