W3A1: Problems that I encountered due to public_tests.backward_propagation_test

Thanks for your careful analysis of what is happening here. Yes, you’re right that the test case here is a bit sketchy. This issue has been known for a long time: here’s a thread about it from November 2021. I filed a bug about this in March 2023, but the course staff has decided that it is low priority enough that they have not done anything about it yet. Note that they literally wrote out the correct code for g^{[1]'}(Z^{[1]}) for you in the instructions. See the “Tips” section right before the function:

If you instead implement it as:

(1 - np.tanh(Z1)**2)

then it passes the first visible test in the notebook, but it fails the one you pointed out that is imported because in that test case it is not true that:

A1 = np.tanh(Z1)

because they just randomly generated A1 and Z1.