Exercise 4 - backward_propagation_with_dropout

Hi all,
I am getting the following error once running the code in Exercise 4 of W1 A2,
backward_propagation_with_dropout, while I passed all the test but for keep_prob = 0.86 in [16].

can anyone please help?

ValueError                                Traceback (most recent call last)
<ipython-input-16-9bfabb849b4f> in <module>
----> 1 parameters = model(train_X, train_Y, keep_prob = 0.86, learning_rate = 0.3)
      3 print ("On the train set:")
      4 predictions_train = predict(train_X, train_Y, parameters)
      5 print ("On the test set:")

<ipython-input-3-0f6a391419fd> in model(X, Y, learning_rate, num_iterations, print_cost, lambd, keep_prob)
     32             a3, cache = forward_propagation(X, parameters)
     33         elif keep_prob < 1:
---> 34             a3, cache = forward_propagation_with_dropout(X, parameters, keep_prob)
     36         # Cost function

<ipython-input-12-bd0abc0e42ea> in forward_propagation_with_dropout(X, parameters, keep_prob)
     44     D1 = np.random.rand(2,5)
     45     D1 = (D1 < keep_prob).astype(int)
---> 46     A1 = np.multiply(A1, D1)
     47     A1 = A1 / keep_prob

ValueError: operands could not be broadcast together with shapes (20,211) (2,5)

Hi @Hamid_ILBEYGI,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.


Hi @Mubsi
here is my lab ID: rkgjwcfj

Hi @Hamid_ILBEYGI,

I took a look at your notebook. Some of the formulas were wrong in Ex 2. And Ex 3, you were using hard coded values. Please refrain from using hardcoded values. You might pass the tests in the assignment using the hard-coded values, but you will fail the autograder tests. I submitted your assignment as well to check, and you got the 100/100 grade.

All of the details have been left as comments in your notebook in Ex 2 and Ex 3.

Happy learning,

1 Like

Thank you @Mubsi .
There is no submission button in the assignment. Could you check that if possible?

solved thank you again

Hi @Hamid_ILBEYGI,

The submit button can be buggy. Make sure, your assignment name is always the default name of the assignment before opening it… And usually, reopening the assignment brings it back.