The cost param passed in exercise 5. However, it fails in exercises 6 and 8. In exercise 6, I am getting the error of – Wrong values for costs. [array(5.80154532), array(0.8074752)] != [5.80154532, 0.31057104]. I used the formula given to calculate the cost.

*{moderator edit - solution code removed}*

Shouldn’t it always calculate the correct value? I want to note that w.T and np.transpose(w), gave me the same value. It is shorter and the code looks cleaner when I use T instead of np.transpose.

That code looks correct. Notice in the error message from the grader that your first value agrees, but it’s the second one that does not. So that means the bug is someplace else: probably either in your “update parameters” logic or maybe your back propagation logic. Of course the *costs* array that is returned by *optimize* contains one entry per every 100 iterations. So it looks like the entry for iteration 100 is where the problem is.

The bug could also be something like over-riding the learning rate on the call to *optimize* from *model* by “hard-coding” the value.

Thank you! The Jupyter notebook on Coursera did not save my work despite the fact that I manually saved the file (I contacted support but could not recover my work). so I have to start over from scratch. I will work on the assignment in Anaconda Jupyter and and paste my code into Coursera. I will pay close attention to the areas you mentioned.

I guess it depends on what you mean by “manually saved the file”. One possibility is that the course staff released a new version of the notebook and your work was saved under another name.

If you already have your own Jupyter environment set up locally, you can use that. Another strategy would be to work in Coursera’s notebook but then save locally by doing “File → Download as notebook”. Note that will give you a file with the extension “.json”, but you can rename it to “.ipynb” if you ever need to upload it to recover your work again.

Thank you! It may not work because I received a ModuleNOtFoundError: No module named ‘lr_utils’

Well, if you want to actually run the notebooks locally, then you need a lot more than just the notebook itself. There is a whole tree of files you need to download. Then you need to get compatible versions of all the python packages installed. It’s a pretty big hassle. I recommend you work in the course environment and then download the notebook to save it.

Ok. Thanks! I had completed the assignment but I did not past Exercise 6 and 8. A lesson learned!

1 Like

If you decide you want to download everything in the future, here’s a thread which shows one method for doing that. But I think it’s not really worth your effort at this point. You need to figure out how to work in the course environment and have your work saved.

Thank you! I found my error. it was in the calculation of w and b. I forgot to subtract the value from the original w and b. I am also using the save but instead of ‘file, save and checkpoint’. That works!

1 Like

That’s great that you found the solution to both the algorithm and the “save” methodology. Thanks for confirming. Onward!