Hi there,
in this assignment I didn’t pass all tests, it is the test call cell of the 2-layer-modell (two_layer_model).
One of the test calls returns: “Error: Wrong shape for variable 0”. By printing out the inputs I see that the test call before uses exactly the same inputs WITHOUT any error. This is weird …
Can you find the mistake? Please see my notebook attached and further description of the problem …
~/work/release/W4A2/test_utils.py in multiple_test(test_cases, target)
140 print(‘\033[92m’, success," Tests passed")
141 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
→ 142 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))
143
AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.
Yes , I used that. I found the problem: I did not use the function compute_cost. If I call that, it works. But it is weird because if I replace the call of compute_cost by those 3 lines of this function (see below) it still does not work. Do you know why?
if 0: # exactly the lines of function compute_cost (does not work - why?!)
m = Y.shape[1] # number of examples
cost = -1/m*(np.dot(Y, np.log(A2).T) + np.dot(1-Y, np.log(1-A2).T))
cost = float(np.squeeze(cost)) # makes sure cost is the dimension we expect.
# E.g., turns [[17]] into 17
else: # this works …
cost = compute_cost(A2, Y)