I’m getting this error when submitting my C2_W3 assignment:
Cell #29. Can’t compile the student’s code. Error: NameError(“name ‘build_and_train_model’ is not defined”)
I’ve defined the full build_and_train_model() function directly inside Cell #29, included all necessary imports, and followed the submission guidelines. The function runs fine locally.
I also tried submitting via Google Chrome and cleared my cache and memory, but the error still persists. I believe this may be an issue with the autograder environment.
That should be for the code cell with the exercise code #UNQ_C5, right? The default code structure for that cell is that it (1) sets the seed, (2) define model_r and (3) compile model_r. It does not require any function named build_and_train_model, and function of such name is not required anywhere in the Machine Learning Specialization Course 2 Week 3 assignment.
Do you think that’s your own creation to have build_and_train_model? If so, in terms of passing the assignment, it might just be the quickest fix for you to fall back to the original structure and complete the step (2) and (3) above. If the original structure was lost, you may follow these steps to get a new copy of the notebook while keeping your current one so that you could move your work over.
If the function was already there and you were just completing it, I wonder if you might be referencing another assignment because as I said in my 2nd paragraph, it only defines and compile, so it does not train (as implied by the name build_and_train_model.
Just wanted to circle back and say thank you for offering insights and support on my earlier Cell #29 and grading issues for the C2_W3 assignment.
After a lot of trial and error — and a huge thanks to your insights — I was finally able to get the notebook structure right. The key was understanding that the auto grader expects model_s = 0 and model_r = 0 as literal values in the graded cells, even if it seems counterintuitive for model-building logic.
I ended up moving all the actual model-building, training, and plotting work to later, non-graded cells using model_s_plot and model_r_plot, and that allowed me to preserve both autograder compliance and local testing.
Final grade: 80%
Still a minor error flagged on model_r, but everything else passed and I’m happy with that!
Thanks again to you and this community — it really helps knowing you’re not alone when debugging something that “should” work but doesn’t.