Error in lab "name 'g' is not defined

Hello everyone I got an error that says, “Cell #8. Can’t compile the student’s code. Error: NameError(“name ‘g’ is not defined”)”. Would anyone be able to assist me with this? The help will be appreciated.

Hi @Moses_Madavaram

Welcome to the community!

There error say that you didn’t set or use the variable g in function sigmoid(z) which should be returned after you compute the sigmoid value so you want to compute the value of the sigmoid like this equation
g(z) = \frac{1}{1+e^{-z}}
and after that you set the value in variable g and return it

Cheers!
Abdelrahman

Strange I’m pretty sure I did that well let me try again and see.

Does the problem solved?

Thanks!
Abdelrahman

I tried it out and the same error still pops up.

1 Like

sorry for didn’t reply as I forgot it but you can try to send me private the screen shot of error and the cell which is the error rise

Thanks!
Abdelrahman


Hello, it said that there were a few functions that said the wrong implementation. I can show you the other function.



HI @Moses_Madavaram
The error say that you have an error in the function compute gradient as you just want to adjust the indentation as in the first for loop over n(features) you want to compute the prediction so that the you only to specify the line of X[…]*W[…] in the indentation of this for loop over n and other is outside this for loop … if you adjust the function compute gradient every error will run correctly

Note the code isn’t be allowed to be shared here

Cheers,
Abdelrahman

It also said that the 6th function was also incorrect.

that’s because the 6th function is depending on the compute gradient function

Hello, I also encountered the same problem. Has this issue been resolved?

1 Like

I am also facing the same issue, tried almost everything, one of the thing is this:


Not sure what code it’s interoperating, such a time waste.

That may not be where the error is. What is the graded feedback for the other functions in the notebook?

If the grader sees an error that makes it crash, it will give the same error message for every function.

Are you trying to use the ‘g’ variable somewhere else in the code you added to the notebook?

Have you renamed your notetook?

@TMosh

he is using g as a numerical value where as he is suppose to write the code to get the return function g, that is also probably one of the error issue

I saw the earlier code which included the correct calculation.

I’m certain that it was hard-coded to 0.5 temporarily to try and sort out the “g is not defined” error message.

1 Like

Hey, I checked it, but g wasn’t defined anywhere else. Also, there isn’t any output for other functions.
I haven’t changed the name of file too. Also, when I am trying to save and checkpoint it’s showing autosave failed error. Not sure whether this is the issue.




When I tried to check for week 2 assignment, I got to know that it was updating the file.

Not sure why save and checkpoint is failing in week 3 assignment. I have also tried to reboot lab and other steps but still nothing working.
Kindly assist me, it seems link I am banned or something :slight_smile:

It seems more like I don’t have access to edit notebook or do any other thing:


Also not able to download any file.

Is your course subscription still valid?

Yes, I enrolled last week only.

Have you paid for the course (or used financial aid), or are you just ending your free week trial?