Test failing for function Forward Propagation with Dropout

I’m having a real hardtime to find why one test case fails for the function forward_propagation_with_dropout in the Regularization assignment.

For the test case

   t_X, parameters = forward_propagation_with_dropout_test_case()

  A3, cache = forward_propagation_with_dropout(t_X, parameters, keep_prob=0.7)
  print ("A3 = " + str(A3))

  forward_propagation_with_dropout_test(forward_propagation_with_dropout)

I’m getting the following results:

A3 = [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
Error: Wrong output for variable in position 0.
Error: Wrong output for variable in position 1.
Error: Wrong output for variable in position 2.
Error: Wrong output for variable in position 5.
Error: Wrong output for variable in position 6.
Error: Wrong output for variable in position 7.
Error: Wrong output for variable in position 10.
Error: Wrong output for variable in position 11.
1 Tests passed
1 Tests failed

Can someone help me realize what I’m doing wrong here?

Edited to remove the code.

Hey! You should check with the instructions if you’ve used the correct random function. I think that should let you fix the issue. Since the random values are used to check if your implementation is right or wrong, this is important.

8 Likes

Hi @rogeriovazp,

I think @XpRienzo is right. With randn you’re sampling from a different distribution, and thus the computed values do not match those in the test case. The notebook tells you the right function to use.

But please be careful when posting code. You’re unintentionally giving away the answer!

Good luck with the rest of the assignment.

6 Likes

Thank you so much @XpRienzo and @nramon ! It was really the random function!

Glad that you were able to solve it! Can you please edit the topic and remove the code now? We’d not want everyone to know the solution now, would we? :grinning_face_with_smiling_eyes:

2 Likes

Thanks for the help! I have been stuck on the same issue for a while -_-’

After punching np.random.randn(), its easy to skip over the np.random.rand() giving 0 or 1 as detailed in the instructions :grin:

I am having this error.
AssertionError Traceback (most recent call last)
in
4 print ("A3 = " + str(A3))
5
----> 6 forward_propagation_with_dropout_test(forward_propagation_with_dropout)

~/work/release/W1A2/public_tests.py in forward_propagation_with_dropout_test(target)
166 ]
167
→ 168 multiple_test(test_cases, target)
169
170 def backward_propagation_with_dropout_test(target):

/opt/conda/lib/python3.7/site-packages/dlai_tools/testing_utils.py in multiple_test(test_cases, target)
162 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
163 raise AssertionError(
→ 164 “Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for forward_propagation_with_dropout. Check your equations and avoid using global variables inside the function.

I tried both with and without using global variables, but I still encountered the same error…

I’ve sent you a private message for further instructions. Please check it out…