Welcome to the community.

Assuming that this is W2A2 in C1…

`dw`

and `db`

are calculated independent to the cost calculation. In your case, `dw`

and `db`

are correct, but `cost`

is not. So, you can just focus on the one single line, cost calculation.

J = -\frac{1}{m}\sum_{i=1}^{m}(y^{(i)}\log(a^{(i)})+(1-y^{(i)})\log(1-a^{(i)}))

Others should be OK.

It works Now thanks. I had used minus “-” sign instead of a plus while writing the code.

However, after that worked, dw stopped working

I tried the same propagate function for solving questin 6 and it worked fine but doesn’t do well on question 5. I guess the wrong test was used in the file.

here is my screenshot of the new problem

I’m afraid that you are using a hard-coded value for the number of samples, `m`

.

As you see in the first line of this function, it is obtained from the shape of X.

With looking at your result, you seem to use `m=3`

always, which is not correct.

Please double check this.

Very true, I did that while I was trying to debug what was wrong with the cost function initially.

All works perfectly now.