Wrong formula in DLS C1 Week4 A1 Exercise 9

I don’t know if it is already pointed out, but there is an error in the formula given for exercise 9 of assignment 1 in Week4 of DLS course 1.

There should be a + sign instead of the - before the second term. Having some knowledge about the math, I identified the error and corrected it, hence my code worked perfectly, but for someone with less knowledge about calculus and if you’re program isn’t working, this might be the issue.

Thanks and All the best!
Yash

Hi, Yash Barve.

You can have an idea from this thread, where the entire chain rule has been discussed in detail. If you fail to get any of the details, then do let us know. We can have it discuss here.

This contains the entire explanation on how we go with the process of chain rule.

Thanks!

I think the formula in this assignment is right.

dAL = - (np.divide(Y, AL) - np.divide(1 - Y, 1 - AL))

Let’s start with a loss function.

\mathcal{L} = -(Y log(AL)+(1-Y)log(1-AL)) \\ \frac{\partial\mathcal{L}}{\partial AL} = -(Y\cdot\frac{1}{AL} + (1-Y)\cdot\frac{1}{1-AL}\cdot(-1)) = -(Y\cdot\frac{1}{AL} - (1-Y)\cdot\frac{1}{1-AL})

So, I think the formula given is right.

I’m afraid that you ignored the first parenthesis like this…

dAL = - np.divide(Y, AL) + np.divide(1 - Y, 1 - AL)

This is absolutely same as
dAL = - (np.divide(Y, AL) - np.divide(1 - Y, 1 - AL))

Yes, Nobu Asai, you are very true :slight_smile:

This one parenthesis makes the whole outlook changed, but the definition and context remains the same.

My bad, I missed the second closing bracket at the right. The formula is correct.

Thanks!