Week 2-Assignment 2 Can't compile the student's code

I have passed all tests in the assignment Jupiter Notebooks. However, after submission, I received 0 grades and the following feedback:

Cell #9. Can’t compile the student’s code. Error: SyntaxError(‘invalid syntax’, (’/tmp/student_solution_cells/cell_9.py’, 16, 1, ‘)\n’))

Any ideas why?

The first thing to try is: Restart the kernel and clear all the output - then run all of the cells again.
Then look closely at every output cell, and see if there are any error messages.

In fact, I did what you proposed before I posted this question. My problem has been solved. It was just because there is a ‘\n’ right after one of the comment lines. There’s no syntax error in the code implementation. I think the grading system is a bit rigid.

Thanks for your report.

Can you be specific about which line had the extra \n, so I can report how to duplicate the issue?

\n after “ImageNet” comment.

Are you referring to here?

Hi, I have a similar error:

Cell #10. Can't compile the student's code. Error: SyntaxError('invalid syntax', ('/tmp/student_solution_cells/cell_10.py', 12, 24, 'base_model.weights=None)#\n'))

I restarted the kernel and clear the outputs but I keep getting the same error (and 0 points). In an earlier version of my submission, I had created a cell (cell 10) to simply look at the model weights. I have now deleted that cell though, rerun the kernel and submitted again. Still getting the same error.

Any leads?

Thank you :slight_smile:

Hi, @MaxAB! Are you sure you’ve done “Cell → Run All” in your notebook and then gone through carefully to make sure none of the cells are throwing any errors?

If your notebook “runs cleanly” as it stands, but the grader throws that type of error, then the other thing to wonder is whether you’ve just accidentally corrupted some structure that the grader depends on. One experiment worth trying would be to get a clean copy of the notebook and then very carefully just “copy/paste” over your completed solution code and see if that helps. There is a topic about how to do that on the FAQ Thread.

Hi :slight_smile: Thanks for the tip - I think the corrupted structure was the issue. I deleted a cell that I had inserted myself and afterwards I was able to submit (somehow a couple of days ago the same trick didn’t work). Thanks!