Week 2 Exercise 5 - propogate function log returns NAN and dimension mismatch

It looks like your sigmoid function is incorrect or you’re not applying it. The A values are the output of sigmoid, so that means they should be between 0 and 1, right? If you take the log of a negative number like -5.9, that will not end well.

I’m guessing the dimension mismatch is on the cost calculation. It’s fine to use the dot product for that, but you need to transpose one of the operands or it doesn’t work. If A and Y are both 1 x 3, then just dotting them as is doesn’t work. The alternative is just to use elementwise multiply (“*”) followed by np.sum. Here’s a thread which discusses this in more detail.

1 Like