An error I’m getting while running L_model_backward() is the following:
TypeError Traceback (most recent call last)
in
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’]))
in L_model_backward(AL, Y, caches)
43
44 current_cache = caches
—> 45 dA_prev_temp, dW_temp, db_temp = linear_activation_backward(dAL, current_cache, activation = “sigmoid”)
46
47 grads[“dA” + str(L-1)] = da_prev_temp
in linear_activation_backward(dA, cache, activation)
35 # YOUR CODE STARTS HERE
36
—> 37 dZ = sigmoid_backward(dA, activation_cache)
38
39 dA_prev, dW, db = linear_backward(dZ, linear_cache)
~/work/release/W4A1/dnn_utils.py in sigmoid_backward(dA, cache)
74 Z = cache
75
—> 76 s = 1/(1+np.exp(-Z))
77 dZ = dA * s * (1-s)
78
TypeError: bad operand type for unary -: 'tuple’
This is what I have under L_model_backward() in the back propagation step:
current_cache = caches
dA_prev_temp, dW_temp, db_temp = linear_activation_backward(dAL, current_cache, activation = "sigmoid")
grads["dA" + str(L-1)] = da_prev_temp
grads["dW" + str(L)] = dw_temp
grads["db" + str(L)] = db_temp
I highly doubt I’m using the wrong function to backpropagate, my guess is I’m either probably misunderstanding what the temp variables are for or I did something wrong in current_cache assignment step.