Course 1 Week 4 Programming assignment #2

I am taking this course through Coursera but was redirected from the Coursera forum to here. In Course 1, Week 4, Programming Assignment 2, function L_layer_model, I am getting output:

Cost after iteration 0: 0.695046

Whereas it says the expected output is

Cost after iteration 0 0.771749

I have literally just retyped the five lines of code given in the text immediately above this function. Any ideas about what I could be doing wrong? I can send you code if you like.

hi @michael.brent, and welcome to the DLS community!

It’s difficult to say from your post where anything went wrong and of course we cannot share immediately the solution.

What I suggest you do:

  • check whether you have executed all previous cells in the same assignment correctly.
  • check whether you did not add any additional code, and have not hard-coded any variables.
  • check/re-check/double-check, and again check/re-check/duoble-check for any typos.

Give that a shot first and see if you can find any mistakes,
regards Stephanus

Hi I think I have the same situation. Although I passed all the tests and successfully submitted the assignment. I’m still wondering, why my model get lower costs in the training: after the first iterations, exactly the same cost as michael: 0.695 after iteration 0, while the expected is about 0.77, then after 2500 still with a lower cost 0.025 than the expected 0.08. So my model is more overfitted right? The train accuracy is a bit higher than the expected, and the test accuracy is much lower than the expected 80%: 74%

There are a number of things out of date with this assignment, such as the comments say it is one version while the file extension has a much higher version number. Is it possible that something has changed and the comment giving the expected value is out of date?

I think Cost after iteration 0: 0.6950464961800915 should be correct, it’s calling the same function with the same parameter as above, why would the result be different? The " All tests passed." accepted 0: 0.6950464961800915 as being correct after 0 iteration just above.

These are my results:
Cost after iteration 0: 0.6950464961800915
Cost after iteration 100: 0.5892596054583805
Cost after iteration 200: 0.5232609173622991

Cost after iteration 2400: 0.026615212372776077
Cost after iteration 2499: 0.024821292218353375

Training set accuracy:
Accuracy: 0.9999999999999998

Test set accuracy:
Accuracy: 0.74

What are yours looking like?

No, my output is:

Cost after iteration 0: 0.6930497356599888
Cost after iteration 100: 0.6464320953428849
Cost after iteration 200: 0.6325140647912677

It looks like they changed the notebook so the expected output now matches this. I wish someone had told me. :frowning:

1 Like

I am super frustrated because last time I worked on Week 4 lab’s I had passed the first one and was essentially done with the second except for the very last step. Because there was something wrong with the cloud server, I couldn’t run it successfully (cells that gave output before stopped giving output). Then I couldn’t work on it for a few weeks and had “reset deadlines”. Now my work is gone. I am no longer listed as “passed” on the first assignment and all my work is missing from both assignments. There may have been a new release of the assignment and it says I should find my old assignment somewhere but it is not listed from the “week 4” list of assignments and I can’t find it with the terminal. Please help as I don’t have the hours or the heart to do this all over again. Thank you.

Using latest version of the assignment, that was last updated on 28 April 2021, 6:10 PM PST
for the “two_layer_model”, I also get 0.6950464961800915 cost on “first” iteration (Iteration 0), but then I also get “Errors” on wrong ouptuts for W1,W2,b1,b2… my behavior seems more like image|690x437 from Issue: Week 4 exercise 4 not passing both tests

Do you “also” get the “wrong ouptuts” error message ?

Did you copy the functions you wrote in w4 first notebook to this notebook? I once did and it gave me wrong output similar to yours.

I got the same thing but I solved it when I realized I didnt run one of the cells