Do you know how to debug this error?
Every time you open a notebook, you have to run all of the cells starting from the top. That is how the environment is created and the assets are loaded.
me to but name error: name âx_trainâ is not defined?
Did you run all of the cells after opening the notebook?
Because x_train is defined by running the cell in section â3 - Datasetâ
Please post a screen capture image that shows the entire error message - but do not include your code.
Im having an error with my Xtrain being defined. I have already defined it in the first exercise but it will still show an error if i dont have the X and y train called. Any help please?
A couple of tips:
-
âx_trainâ is defined when you run the first cell in section â3 - Datasetâ.
-
Every time you open the notebook, you must run all of the cells starting from the top.
-
Inside the compute_gradient() function, it doesnât use the âx_trainâ variable. If you look at the function definition, it doesnât menttion âx_trainâ.
It uses the variable âxâ. This is the local variable you should use when you add code to that function.
Hi! Thank you so much for your help. I am still a little confused do you mind explaining a little more please? Thank you so much! I have ran all the cells and it still has the error
I got rid of the X and y train in the second part of code but now it has this error
Python defines blocks of code using indentation.
These two lines of code are indented so that they are inside the for-loop. This means they will run on every trip through the loop, so youâll be doing the âdivide by mâ too many times.
They should be out-dented (if thatâs a word?) one level, so they are only executed once, after the for-loop ends.
A reminder: Please do not post your code on the forum, thatâs not allowed by the Code of Conduct. If a mentor needs to see your code, weâll contact you with instructions.
Ok thank you so much! Iâm so sorry i took it out
No problem.