It looks like you are using elementwise multiply "*" in the “linear activation” calculations. That is not what the math formula tells you to do. It is important to realize the notational convention that Prof Ng uses: when he writes a math formula with two operands adjacent with no explicit operator, then the operation there is “dot product” (np.dot), not elementwise multiply. When he means elementwise, he will always explicitly use “*” as the operator. So this formula:
Z = WA + b
Really means this:
Z = W \cdot A + b
Here’s a thread which discusses this point in more detail.