Error on submission

I did the tasks in the lab with vectorization, so I did not use any for loops, each task in 3 lines each, it passes all the tests and it gives me 0% on grading. Also I did not delete any hashtags or anything from the cell.

LinkedIn: Salman Chishti - Product Manager at 2 Microsoft

Hi @SalmanMKC! , do the grades output the following information?

Code Cell UNQ_C1: Function ‘compute_cost’ is correct.
Code Cell UNQ_C2: Function ‘compute_gradient’ is correct.

Hi @SalmanMKC

If you pass all tests , the suggestion from the course staff is that you should rename your notebook, get a fresh copy of the notebook (using the “Help” menu), and then hand-copy your code from the old notebook to the new one.

No it outputs that they are incorrect. But all the test cases are showing they are passed.

Okay, I created a copy and ran everything again, still tests are passing and now submitted again and again it failed with 0%

If I submit again it will be the max attempts. Can someone just manually verify that my code works and then pass it? I don’t like that it should have been 100% on the first attempt and now it’s on my record as 0% twice.

Hello @SalmanMKC,

Could you please share a screenshot of the grader’s output?

Where did you see that there is a max attempt?


When the grader gives you 0%, it means your code doesn’t work correctly with the grader’s test case.

Oh maybe it doesn’t on this course, thought there was max

Then why does it say that all tests are passed for both questions? I’ve already stated this

“All tests passed” refers to the test cases that are built into the notebook.
They are not a comprehensive test of your code.
The grader uses different tests.
Your correct code should work with all of them.

So there are ‘edge’ cases? These are simple maths calculations, please give me an example which should work outside of the notebook tests if this is the case.

So is anyone here able to answer this? What kind of edge cases are there that aren’t included? This is not some algorithmic question where I am supposed to check for edge cases, such as sanitizing inputs for empty strings, so I have no idea what can cause it to get 0% but pass all test cases.

Hi @SalmanMKC those are just different situations with different input and different outputs. There are public test and private test to make sure you actually have the right calculation. It seems that there are some differences in the way you calculate the results and the way it’s expected to get the results, maybe you can try to check again the code, and if that doesn’t solve your problem you can check the hints and see if there is something that you missed.

Checking the hints won’t hurt your grade, and it’s also a great learning opportunity.

Hope this helps.

Try implement it using vectorization and check if it works, because it should. I am not rewriting my code to use for loops just for this exersize if it can be done in 3 lines.

I would say take it as a learning opportunity, sometimes to show how some concepts work, it’s needed to present the material differently so most learners can pick up how things work. Unfortunately, it would have low complexity (even inefficient for some learners) and it would be really difficult to understand for other learners. In the lectures, it’s pointed out that those implementations are just to understand the concept, and in natural settings, you won’t have to implement linear regression and most of the algorithms by themselves.

So, given that you already have the basics, I would suggest just submitting the solution that is required and keep learning, as you move on through the specialization the concepts will become harder and the implementation will be more efficient.

Hope this helps!

Looking at the hints, it even mentions you can do it with this approach though. And the lecture material did say instead of using a for loop we can use vectorization, from my impression they seem to suggest that it is better, as certain calculations for example the dot product will run on multiple threads.

You should be able to use a vectorized solution and it sounds like you’ve checked the usual suspects for what could be causing a grader error. Could you DM me a copy of your ipynb file for the assignment and I’ll see what I can figure out about what the grader is choking on. You may have found something that should be fixed on the grader end.

They’re not “edge cases”. They’re normal sets of data with no tricks.

Examples of potential mistakes in your code can include assuming that all data sets have exactly the same number of examples, or exactly the same number of features.

Your code should solve the most general case.

Also, your code should avoid using any global variables that may be used in the notebooks. Those global variables are not within the execution scope of the grader.

The grader does not care how you write your code. It only tests the return values.

Okay hi everyone, my trial ran out and I did not continue with the course, I thought Coursera Plus included this. I bought the subscription now, and so basically I’m sorry, what I did was I made a copy of the file, and whenever I was submitting I was submitting the original file which is why it was failing all the time, as soon as I put my code into the original file, literally just copying and pasting, it passed the whole assignment.

Hello @SalmanMKC,

Thank you for sharing your solution with us!