DLS course 1 Week 4 programming assignment one

Hi There,

I cant figure out why I’m getting this bug. It has something to do with the caching. Not sure if I’m allowed to share my code or not.

[ValidateApp | INFO] Validating ‘/home/jovyan/work/submitted/courseraLearner/W4A1/Building_your_Deep_Neural_Network_Step_by_Step.ipynb’
[ValidateApp | INFO] Executing notebook with kernel: python3
Tests failed on 1 cell(s)! These tests could be hidden. Please check your submission.

The following cell failed:

t_AL, t_Y_assess, t_caches = L_model_backward_test_case()
grads = L_model_backward(t_AL, t_Y_assess, t_caches)

print("dA0 = " + str(grads['dA0']))
print("dA1 = " + str(grads['dA1']))
print("dW1 = " + str(grads['dW1']))
print("dW2 = " + str(grads['dW2']))
print("db1 = " + str(grads['db1']))
print("db2 = " + str(grads['db2']))

L_model_backward_test(L_model_backward)

The error was:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-20-3ace16762626> in <module>
      1 t_AL, t_Y_assess, t_caches = L_model_backward_test_case()
----> 2 grads = L_model_backward(t_AL, t_Y_assess, t_caches)
      3 
      4 print("dA0 = " + str(grads['dA0']))
      5 print("dA1 = " + str(grads['dA1']))

<ipython-input-19-ecec27d3ac08> in L_model_backward(AL, Y, caches)
     59         # YOUR CODE STARTS HERE
     60         current_cache = caches[l]
---> 61         dA_prev_temp, dW_temp, db_temp = linear_activation_backward(dAL, cu...
     62         grads["dA" + str(l)] = dA_prev_temp
     63         grads["dW" + str(l + 1)] = dW_temp

<ipython-input-17-32d5362f61a8> in linear_activation_backward(dA, cache, activation...
     22         # dA_prev, dW, db =  ...
     23         # YOUR CODE STARTS HERE
---> 24         dZ= relu_backward(dA, activation_cache)
     25         dA_prev, dW, db =linear_backward(dZ, linear_cache)
     26         # YOUR CODE ENDS HERE

~/work/submitted/courseraLearner/W4A1/dnn_utils.py in relu_backward(dA, cache)
     54 
     55     # When z <= 0, you should set dz to 0 as well.
---> 56     dZ[Z <= 0] = 0
     57 
     58     assert (dZ.shape == Z.shape)

IndexError: boolean index did not match indexed array along dimension 0; dimension ...

That means that the dA value and the activation cache value that are being passed down to linear_activation_backwards do not match. It looks like within the loop over the hidden layers, you are always passing dAL, which is only for the output layer, right?

Thanks for the clarification!