Exercise 4 - C1_W3_Assignment

Hello, I’m encountering an issue with the fourth exercise in C1_W3_Assignment. Although the code produces the expected output in the notebook, I face an error when attempting to test it. The error message reads: “forward_propagation() takes 2 positional arguments but 3 were given.” Here is the relevant code snippet for your reference. Any assistance in resolving this matter would be greatly appreciated.

Code
def forward_propagation(X, parameters):
“”"
Argument:
X – input data of size (n_x, m)
parameters – python dictionary containing your parameters (output of initialization function)

Returns:
Y_hat -- The output
"""
# Retrieve each parameter from the dictionary "parameters".
### START CODE HERE ### (~ 2 lines of code)

{Codes removed by Moderator} ### END CODE HERE ###

# Implement Forward Propagation to calculate Z.
### START CODE HERE ### (~ 2 lines of code)

{Codes removed by Moderator} ### END CODE HERE ###

assert(Y_hat.shape == (n_y, X.shape[1]))

return Y_hat
3 Likes

This error almost always means you’re using an obsolete copy of the notebook file.

Where did you get your notebook file from?

1 Like

even im facing the same issue. i tried @TMosh 's way of updating the notebook, still i encounter this frustrating issue. imo one of the worst experiences i had w/ a coursera course.

1 Like

If you are following the method of getting a new copy of the notebook (i.e. delete your current notebook, then use “Help->Get latest version” to get a new notebook), then you will find that the new notebook uses three parameters for the forward_propagation() function.

You may also need to use “Kernel → Restart and clear output”

If you look at your notebook and see that forward_propagation() only takes two arguments, then you are still using an old copy of the notebook.

have done this:

Here is the FAQ. Follow the method in Topic 1 - there are several other steps you have to do before you use “Help → Get latest version”.

https://community.deeplearning.ai/t/math-for-machine-learning-faq/443624

1 Like

Yes, I just gave the short summary here.

I recommend you use the method in the FAQ that is referred to as Topic 1b.

okay, if the issue persists even after updating… where can i access the latest version of notebook files?

1 Like

Please refer this, follow the 1(a) to get a totally fresh copy of the assignment

2 Likes

hello! i tried what is mentioned in topic 1b @Deepti_Prasad and @TMosh . but still the error preserves. is there another option of submitting my work and grade it? other courses i have done so far with lab exercises usually had another way of submitting my work other than the from the jupyter workspace. please help me in this, my deadline’s closing by.

1 Like

Hello @Supun_Wijesooriya,

I told you to use 1(a) topic if the 1(b) didn’t work, the difference between these two topic is 1(a) requires deletion of your assignment files and then rebooting, getting the latest version with Updating the lab. Please go through each step in 1(a)

Also to be on safer side, after you delete the assignment file, make sure you clear your browsing and cache history, log out of your coursera. Then re-login, go the assignment page before you do the rebooting and getting the latest version.

Let me know if after following 1(a) resolved your issue or not.

Regards
DP

1 Like

No, there is not.

The way you get the current version of the notebook is by following the instructions in the FAQ exactly. The instructions are known to be correct.

it doesn’t work as well @Deepti_Prasad i tried topic 1a as well. how to resolve this issue?

1 Like

Please read our previous replies. The procedure is known to work.

i have read all the previous replies @TMosh . thank you for the support.

1 Like

Hello @Supun_Wijesooriya,

That’s ok. I am sharing a post where I guided the learner step wise on how to get the fresh copy, sharing the link, kindly go through all comments for better understanding.

If any doubts, feel free to ask.

Regards
DP

1 Like

yes im here. :innocent: i did everything as you instructed ma’am. i even tried modifying the code of the unit test file it is the error message that im getting. i modified the unit test file with the “new” unit test file i found on a github repo. though i get “all test passed” this time unlike before, still when i submit my work auto grader still outputs the same error and i get 0 though my work is flawless.

P.S i was at the university all this time ma’am.

1 Like

You are not suppose to modify any codes in the unit test file.

My link was about how to get a totally fresh copy, so did you get the fresh copy of your assignment?

1 Like

i did what you have asked ma’am. i even deleted the folders and got the 404 page. and then i opened an incognito tab and accessed the assignment and went to juputer notebook. as expected it was 404 and then i hit get the latest lab file button and got myself the files. but i don’t know whether they’re the new ones or not.

because it says it was modified 3 months ago after i get the new files.

1 Like

Did you reboot before you get the latest version and update lab? Or directly updated lab?

It shows 3 months ago then probably it is the latest file.

Regards
DP