Porgraming Assignment foe Week four of Course 1

{mentor edit: code image removed}

Im triyng to enter this code in differnt wys, but it keeps giving an error message. Does anybody have any suggestions? What is the correct code. I refreshed the Kernel many times, but it keeps saying error message

Please do not share your code on the forum for the course assignments. That is not allowed by the Code of Conduct.

Just posting your error messages is usually sufficient to diagnose the problem.

The error mesage says that “grads” is not defined.

Perhaps that is because you seem to have deleted some of the code at the start of the two_layer_model() function, as shown here:


That’s where “grads” is defined.

Tip: Do not modify the notebook in ways that the instructions do not mention.

Hi Tom,

Thanks for your response! I did try this snippet you sent; it still si giving the error message. Fortunately, It was addressed on the website, and I’ve [retty much completed the first course assignments, so I plan on starting course 2 on May 1st.

Regards,
Niranj

Be sure you save your changes to the notebook before you run any of the tests or send it for grading.

And first run all of the cells starting from the top of the notebook. That verifies that the state of the notebook is as expected.

I did!

Do you need help at this time?

Hi Tom,

Thanks for getting back! As mentioned, I tried everything, including following the code you sent, but the error persists. Not to worry, I saved the code and the changes in the notebook.

If I need any other help in the remaining courses, I’ll reach out to you.

Regards,
Niranj

If the error is still about “grads not defined”, then it must mean that you still haven’t completely restored the code that Tom was pointing out that was just provided to you in the template. One way to pursue a solution here would be to get a fresh clean copy of the notebook and then carefully “copy/paste” over just your code from the “YOUR CODE HERE” sections. It’s not illegal to modify code outside those boundaries, but you need to be very careful that you know what you are doing when you “go there”. Just deleting a bunch of lines they gave you if you’re not sure what they are for is a warning sign. The better approach is to study the template more carefully to understand the purpose of the lines in question.

Here’s a thread about how to get a clean copy of any of the notebooks in DLS if you are using the Coursera platform to take the courses. That link is also available from the DLS FAQ Thread, which is worth a look just on general principles if you haven’t previously seen it.

I did restore the code exactly as Tom gave it, but it keeps giving the error message. I guess it really.is a glitch. If it persists, I’ll reach out to the course instructor .

The course instructors do not listen here. It sounds like it’s time to actually look at your notebook. We can’t do that on a public thread, but please check your DMs for a message from me.