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?