C2 - Week1 - Assignment 2 [Regularzaitons]

i’m having some problems in Exercise 3 - forward_propagation_with_dropout

this is the my peace of code

{moderator edit - solution code removed}

and this is the error

A3 = [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
1 Tests passed
1 Tests failed

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.

Please take a more careful look at the instructions. You should be using the Uniform Distribution there, not the Normal Distribution. Meaning that you are using the incorrect random function to generate the D1 masks. Everything else looks correct.

I assume your code for layer 2 is analogous …

1 Like

i already solved it
i used random.randn() , instead the correct one was random.rand()
what are the differences Mr paulinpaloato ?

1 Like

They use different random distributions. The randn call gives you a normal distribution with \mu = 0 and \sigma = 1. That is not useful for our current purposes. That is the traditional “bell curve” centered at 0 with most values in the range [-3,3]. “rand” gives the “uniform distribution” on the interval [0,1], which is what we need for this application. Think about what it is we are trying to accomplish with the mask values. Having uniformly distributed random values between 0 and 1 is what we need here.

2 Likes