C2W1 Regularization - Issue with assignment, possible bug

Hi there,

I have completed the code in the Regularization notebook and all the tests have passed. However, after submitting it, it shows a score of 60/100. The grader output only says “Tests failed on 1 cell(s)! These tests could be hidden. Please check your submission.” without providing any details.

There is an issue in the notebook that I have come across that might cause this problem. In the cell “GRADED FUNCTION: forward_propagation_with_dropout”, the dimension of W1 is (2,3) and not (20,2) as stated in the comments. Also, the dimension of b1 is (2,1) and not (20,1). I printed the dimensions for W1 and b1 to check. When I then set D1 to np.random.rand(2, m), it passes the test for that cell. However, further down in the code, in the cell that runs the prediction (the cell that starts with “parameters = model(train_X, train_Y, keep_prob = 0.86, learning_rate = 0.3)”), it throws an error since it expects D1 to be of dimension (20,211) instead of (2,211). This error can be fixed by changing the definition of D1 in the function “forward_propagation_with_dropout” to D1 = np.random.rand(20, m).

After it passed all tests, I hit Submit. The grader however tells me that there is an error and I only get 60/100 while it should give me 100/100. Does the issue with the dimensions create this problem? What can I do to get the grader to pass the assignment? I have tried all kinds of things including restarting the Kernel, but it always grades it the same, with 60/100.

Thanks in advance for your help!!


Your code is tested using multiple test cases, of different sizes.
Your code must work for any size of data set.

I recommend against using hard-coded dimensions.

Many thanks TMosh for the hint! This now worked. :smiley: