I am getting incorrect value for cost in Exercise 6. Can you please let me know what am I doing wrong here?

Exercise 5 outputs were verified to be correct. Below is my implementation for the cost

*{moderator edit - solution code removed}*

I am getting incorrect value for cost in Exercise 6. Can you please let me know what am I doing wrong here?

Exercise 5 outputs were verified to be correct. Below is my implementation for the cost

*{moderator edit - solution code removed}*

Welcome to the forum @reeshav!

My advice is to check your usage of np.sum() and/or np.dot() in your computation of the variable `cost`

in Exercise 5.

Let me know what you find!

The code you show looks correct. In fact if you look carefully at the failed assertion message, you will see that your first value of the cost (the one at 0 iterations) agrees with the expected value. The one that is wildly wrong is your second value (100 iterations). So your basic cost computation is correct, but there must be something wrong with either your back propagation or the way you are updating the parameters. Actually the back prop calculations looks correct also. Iâ€™ll bet youâ€™re doing something like using â€ś+â€ť instead of â€ś-â€ť in the parameter update. Notice that your cost is growing rather than shrinking. Hmmmm.

Hi, I have the same problem. I donno whatâ€™s wrong and getting very small values. However, i got correct db value.

My guess is that you do not have the latest version of the notebook. There was a version with a bug in it that was fixed maybe 36 hours ago, but perhaps either you havenâ€™t closed and reopened the notebook since the fix or maybe they didnâ€™t make it a â€śforce updateâ€ť.

There is a topic on the FAQ Thread about how to get a clean copy. Then carefully â€ścopy/pasteâ€ť over just your solution code to the new version and see if that fixes the issue.

Itâ€™s working. Thanks!

Hi, Iâ€™m having problem with the cost function, my code seems to be fine, but it doesnâ€™t match with the expected output.

If you have two row vectors, please note that v^T \cdot w and v \cdot w^T do not give you the same result. The way you have implemented your cost computation is incorrect. The mistake is present in the original post on this thread, but I missed it the first time around. Please see below for a link that discusses the issue here in more detail.

Hereâ€™s another recent thread which shows examples of the difference between the two ways of doing the transpose + dot product.

1 Like