Week 1 ex 2 forward_propagation_with_dropout error

No, that should not be necessary. It looks like perhaps you are not familiar with how “named parameters” work in python. That is just giving the default value of that parameter, if it is not passed in on a particular call. Try googling “python named parameters” and spend 10 or 15 minutes reading up on that.

I know what is that, kinda parameter by default
BUT - here, it this case, function did not work properly before I removed the value
maybe testing system fault

Sorry, but that means something else is wrong with your code.

Is it possible to try again, if I already passed this test ?

You can submit the assignment as many times as you like. The system is smart enough to remember your best score.

I got the same error as 83daemon.
I use np.random.rand(dim, 1) with dim = 1rst dim of A[l]
I use (D < keep_prob).astype(int)
I multiply D1 by A1 so that I have a matrix of shape A1 with some nul row
I divided A1 by keep_prob.
I cannot figure out the problem.
I tried to restart the kernel but nothing works.
Any hints would be much appreciated.
Thanks

I figure it out:
the dimension of the random matrix was not right.

Glad to hear you found the solution! That issue was also discussed earlier on this thread. That post is worth a look as it gives a link to a thread which discusses in detail the point that the mask does not treat each sample within the given minibatch the same way.

Yes. I was getting the error due to typing randn instead of rand. As randn will generate a normal distribution, that is why the solutions were not matching.

I am getting same type of error but cant figure it out /W1 = [[0.00550798 0.00708148 0.00290905]
[0.00510828 0.00892947 0.00896293]]
b1 = [[0.]
[0.]]
W2 = [[0.00125585 0.00207243]]
b2 = [[0.]]
2 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
4 print("W2 = " + str(parameters[“W2”]))
5 print("b2 = " + str(parameters[“b2”]))
----> 6 initialize_parameters_random_test(initialize_parameters_random)

~/work/release/W1A1/public_tests.py in initialize_parameters_random_test(target)
65 ]
66
—> 67 multiple_test(test_cases, target)
68
69 def initialize_parameters_he_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 initialize_parameters_random. Check your equations and avoid using global variables inside the function.

yes also used rand and still error

using RAND “”"

{moderator edit - solution code removed}

eorr becomes

1 = [[0.00550798 0.00708148 0.00290905]
[0.00510828 0.00892947 0.00896293]]
b1 = [[0.]
[0.]]
W2 = [[0.00125585 0.00207243]]
b2 = [[0.]]
2 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
4 print("W2 = " + str(parameters[“W2”]))
5 print("b2 = " + str(parameters[“b2”]))
----> 6 initialize_parameters_random_test(initialize_parameters_random)

~/work/release/W1A1/public_tests.py in initialize_parameters_random_test(target)
65 ]
66
—> 67 multiple_test(test_cases, target)
68
69 def initialize_parameters_he_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 initialize_parameters_random. Check your equations and avoid using global variables inside the function.

changed this and still got error ?? 1 = [[0.00550798 0.00708148 0.00290905]
[0.00510828 0.00892947 0.00896293]]
b1 = [[0.]
[0.]]
W2 = [[0.00125585 0.00207243]]
b2 = [[0.]]
2 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
4 print("W2 = " + str(parameters[“W2”]))
5 print("b2 = " + str(parameters[“b2”]))
----> 6 initialize_parameters_random_test(initialize_parameters_random)

~/work/release/W1A1/public_tests.py in initialize_parameters_random_test(target)
65 ]
66
—> 67 multiple_test(test_cases, target)
68
69 def initialize_parameters_he_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 initialize_parameters_random. Check your equations and avoid using global variables inside the function.

i reset Kernel / reloaded and same error / so frustrating /

There are a number of things to check. You’re avoiding the “randn” mistake and using “rand”, but there are other issues:

Did you make sure that your mask matrices are the same shape as the A matrices, not column vectors?

Did you remember to do the reverse scaling?

If neither of those clues helps, then it’s time to see your code, but that we can’t do here. I’ll send you a DM about that.

Oh, sorry, you are talking just about the initialization. This thread is not about that function: it’s about the forward propagation with dropout in the Regularization Assignment. It is for the Dropout masks that you use np.random.rand. For the initialization you are supposed to use np.random.randn. The instruction are clear on that point.