Week 3 ML Specialization Programming Assignment

Hi there. For the Specialized Machine Learning Programming Assignment at the end of Week3, all my code passes all the built-in tests and gets all the correct answers, but on grading I get errors in UNQ_C5 and 6. I’ve checked the hints and extended hints and I can’t see what is wrong. I used += instead of writing separate lines, but I even copied the given format to see if that was the problem and I still get an error.
Below is my code. Please help! Thanks very much.

This is my code for UNQ_C5:

### START CODE HERE ###

{code removed}

### END CODE HERE ### 

and for UNQ_C6:

### START CODE HERE ###     
{code removed}
    
### END CODE HERE ###

Please post your error messages (via screen capture images), not your code.
Thanks!

Hi @Justine23,
I removed your code from your post since it’s against community guidelines to share answers to the student portion of the code. Just something to keep in mind for the future.

As far as the problem you’re seeing - I don’t see anything obvious wrong with your code.
Ideally, the grader shouldn’t care how you implemented the code, but just that it gets the right result, so the += shouldn’t matter.

Can you share a screenshot of the error you’re getting from the grader?

Hello Justin,

There is error in your code implementation

For UNQ C5

START CODE HERE

for j in range(n):
    reg_cost_j = Calculate this as per the hint given
    reg_cost = use reg_cos_j here as per the hint given.  refer hints again.
reg_cost = Here there is a tuple error. Write this code same way as per given in the hint section
### END CODE HERE ###

For UNQC6

START CODE HERE

# Loop over the elements of w
for j in range(n): 

    dj_dw_j_reg = (your code line don't match with the equation grader is looking for.  Do this correction again by refering to the hints.  you have written the codes for dj_dw[j] but those codes are for dj_dw_j_reg

    # Add the regularization term  to the correspoding element of dj_dw
    dj_dw[j] = this is you know what to write from the above code equation.
    
### END CODE HERE ###     

Do this corrections, you will pass the grader.

Regards
DP

2 Likes

Actually, @Justine23,
Can you still share the error you are getting from the grader? There are many ways you could write this portion of the code, but I just tried submitting using the code snippets you shared, and I get no errors from the grader. I suspect the error you’re seeing is due to something else - maybe something you inadvertently edited somewhere else in the code.