Hello has anyone encountered this issue like I did? The issue is “NameError: name ‘plot_decision_boundary’ is not defined” for a cell that is not designed for students to code for exercise/tests. This caused the grader keep outputing “Cell #25. Can’t compile the student’s code. Error: ValueError(‘x and y must have same first dimension, but have shapes (2,) and (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2)’)” even though I have passed all the exercises’ cells. And the this cell CANNOT be edited. Any idea of what’s problem of this and how to fix it?
Have you run all the previous cells including the imports at the top?
Those look like two completely different problems. Gent has given you the answer for the second one. For the errors from the grader, there must be a bug (or bugs) in your code that you will need to find. Unfortunately the errors sometimes hard to track down to the particular line of code. You can try using the “Cell #25” as a clue. Note that to get consistent numbers for the cells, you have to execute from a clean state as in:
Kernel → Restart and Clear Output
Cell → Run All
Then look carefully at the cell numbers shown on the left column with the output.
Yes I ran through from the top ‘import’ cell.
The other cells all were tested for a correct pass check. The tricky part here is this bugging cell doesn’t allow to edit. Or I can give it a try to see if I can locate the bug.
Yes, the test cells may not be editable. If the test fails, the solution is not to change the test: it is to find the bug in your code that is triggering the test failure.
If what you are saying is that all the tests pass in the notebook, but then the grader fails, that most likely means that there is some way in which your code is not general. Meaning that you have hard-coded the solution so that it matches the expectations of the tests in the notebook, but fails when the grader uses a different test case. One example of that type of bug would be referencing global variables instead of the parameters passed to your functions.
Hey i failed to solve it due to the overdue of lab but after some re-analysis, i think the reason may be like you said ‘code is not general’. Thank you all the same!
Hi, has it been solved?
I have the same problem: all tests are passed but error: Only “ValueError: x and y must have same first dimension, but have shapes (2,) and (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2)“, which doesn’t explain what actually is wrong.
Yes, the error message may be a little hard to interpret, but the key point is that it is showing that your y value has a completely crazy shape. I’m not even sure off hand how you could create that effect, but it looks like your y has roughly 20 separate dimensions.
Is your case like the one earlier on this thread in that you’re sure that you pass all the test cases in the notebook? If so, then you need to look for ways in which your code is not general.
Yes, my case is exactly like the one in this thread and many others posted on this forum.
I found at least 5 threads complaining about it without clear solution in the end.
’All tests passed!’ and then message which doesn’t explain what was wrong.
If you’re getting that error from the grader, it means your code in the assignment only works with the assignment’s test cases, but it doesn’t work with the grader’s test cases.
The grader uses different tests than those in the notebook.
Usually this happens when your code is using some data or variables that are different when the grader is running your code.
The grader extracts your code from the notebook, and tests it in a different runtime environment.
So if your code has any hard-coded values or uses any of the notebook’s global variables, your code probably won’t work with the grader’s tests.
When we see this instances where the notebook’s tests aren’t sufficient to check your code, we can ask for additional tests to be added.
Thank you for the explanation about how grader works but it doesn’t help in my case.
I don’t have any hard-coded values to match test cases expectations and my implementations use only input variables.
OK.
{edited reply}
It’s resolved. My implementation of sigmoid() added one extra dimension to output ndarray.
Surprisingly, but all test cases passed.
It would be very helpful if test designers also add test cases checking output type, shape, etc. Thank you @TMosh and @paulinpaloalto .
Hi George. Thanks for this feedback, and we’ll look into improving the test cases. May I know if you’re using Coursera or the DeepLearning.AI platform to take this course?
Hi Chris, I’m using Coursera.
Copy. If you don’t mind and can still download your previous failed solution, please send it to me via direct message. You can click my name then the blue Message button. If not, it’s okay. Thank you!
Chris, we have a copy in a private chat, I’ll add you to that thread.

