It looks like the A_prev
value that you passed to linear_activation_forward
for the output layer is not what you are expecting. Please take a careful look at how the variables will stand when you fall out of the “for” loop over the hidden layers.
The other good thing to do here is to first go through the “dimensional analysis”, so that you know what should be happening at each layer. Here’s a thread which takes you through that for this particular test case.