W3 assignment - Grading

Hello,

I did the programming assignment in W3 for AI for Medical Diagnosis / Image Segmentation on MRI Images. I struggled with the first exercise, so not all the tests passed. However, on the next 5 exercises all the tests passed. Yet, the assignment is graded as fail with the following message

Cell #6. Can’t compile the student’s code. Error: AssertionError(‘Not all tests were passed for get_sub_volume. Check your equations and avoid using global variables inside the function.’,)

Can somebody help me check the code and reflect the grade in my coursera?

Thanks in advance

check if any of the grade cell you are using global variable where as you are suppose to use the assignment call argument for that particular grade cell, like in general true positive cases were recalled as true_positive but for particular grade cell true_positive cases were recalled as TF, so here in one of function code, you were suppose to use TF but instead you used true_positive.

Hi Deepti,

Thanks for your quick response. I have checked all the cells and I believe I’m not using global variables, only the ones in the grading cell. Would it be possible to send the code to get some assistance? My main concern is the grade, I believe I have 5 exercises correct out of 6. Thanks in advance

hi @ardonp

Please click on my name and then message. Please make sure to send screenshot of grade cell codes you are suspecting you are having issue and do not send codes my copy paste.

Please make sure not to post any codes here on public post as it is against community guidelines.

Regards
DP

hi @ardonp

You seem to have edited codes and instructions between the assigned markers ###START AND END CODE HERE### which you are not suppose to do.

First get a fresh copy and re-do the assignment(make sure you saved a copy of your old file so you can compare them for your learning), and then mention codes only between the assigned markers ###START AND END CODE HERE###

Codes which required corrections:

  1. then for the first code line where randomly sample the sub-volume, You are suppose to add + 1 to all the samples which you have not done according to instructions provided before the grade cell.

  2. one hot encode the categories, you again seems to have deleted the instructions which would have helped you to write the codes correctly as you are suppose to use keras.utils.to_categorical to y, while adding 4th dimension num_classes.

  3. you are calculating background ratio incorrectly. The instructions mentions this has been implemented for you, that mean you do not use y_one_hot[…,0](THIS IS INCORRECT)

it should be y[:, :, :, 0]/Here your code is correct

  1. While changing dimensions of X and y, as you use the transpose function you are suppose to mention the axis and not use value dimension x, y and z.
    I suspect most of your error were caused either because you deleted the instructions already given in the assignment or not correlating them with the instructions given before grade cell.

Also please note in all assignment grade up to here doesn’t work. These features is only provided in some course and not here.

even a minor typo can be detected as autograde failure. So doing assignment as per instructions is mandatory.

Regards
DP

Hi @ardonp

I checked your other exercises, although your code implementations are correct, there could be two issues why you might still be failing the autograder.

for grade c2 to c5, you have edited the codes and instructions given when you must have first opened the assignment.

You also have removed markers ###START AND END CODE HERE### exercises c2 to c5, which again autograder fails you for this.

from c2 to c5 codes had 3 codes to be written

dice numerator, dice denominator, dice loss, dice coefficient, but for some cells you have hard coded the path, so that again fails on autograding.

Lasting in c6 where you calculate
sensitivity and specificity, use only tp, fp, fn and tn to calculate, do not add any else statement, that is not required.
sensitively is tp/(tp+fn) that’s all

There is also error where it tells you check std mean is not absolute equal to 0, centered_scaled by std mean(here use np.std, this you have recalled std mean using np.std but this might again be considered as hard coding the path as here you have added if else statment which was not required but your code implementation is not incorrect in general but as autograde might fail, so I am just letting you know.

So overall as you have made many changes, the best step forward is to first get fresh copy of the assignment, and then only write codes between the assigned markers and replace None with the correct codes without hard coding the path.

Regards
DP

Hi Deepti,

Thanks for the help and the patience.
I have returned to a clean version of the code put my implementation only inside the #START AND END CODE HERE#

I have summited again and I get the exact same error as before: Cell #6. Can’t compile the student’s code. Error: AssertionError(‘Not all tests were passed for get_sub_volume. Check your equations and avoid using global variables inside the function.’,) Might this mean is not checking the rest of the exercises?

I don’t fully understand what does hard coded the path mean? I’m attaching the exercises 2 to 5, please let me know where is the hard coding part.

Thanks in advance for the help

posting codes from grade cell is against community guidelines, violating code of conduct can cause action by deeplearning.AI. Kindly refrain from posting codes in public posts

You are getting the exact error because you repeating the same mistake of editing and adding code line path than directly recalling

hard coding path means as You have been already given to recall some codes like dice numerator, dice denominator and dice loss, but you recalled disc numerator and and denominator with a part of the recall code and then used other part of codes while recalling dice loss, like in your case, you have added epsilon in the dice loss, dice coefficient which doesn’t mean its incorrect but in the case the autograder has been assigned to look codes in particular way and it doesn’t matches with programmer frame of codes, it can still throw error or grade failure.

@ardonp I already mentioned to you not to post codes on public post, please go through faq section in detail for How to Use the Forum Code of Conduct

you can DM the codes with what correction you have done but how much I saw you still repeating the same mistake, I have shared images below on how it looks when a fresh copy is downloaded and jn that only None need to be replaced with correct codes, no extra code lines required.

You are suppose to only replace None (in green) placed between the markers ###START AND END CODE HERE### with the right codes, see the image below

Don’t add any other extra code lines, just replace None with the right codes

hi @ardonp

if you read my previous comment I mentioned one of the mistake you have been doing it repeatedly of adding epsilon in the last line of code, where as you are suppose to mention the epsilon directly for the numerator and denominator. (I have highlighted the section of previous comment, so you read it again)

and then pass the values to the dice loss, dice coefficient.

Do this correctly and submit again.

please inform me of the progress here other than posting codes here.

Thank you
DP

@ardonp

you didn’t do this correction mentioned in my first comment response to your debugging. Please read the comments carefully and follow each of them one by one.

I understand the discomfort, but debugging requires patience, attention to detail and more self-reflection.

The instructions mentions to change the dimension of X and y from the x dim, y dim, z dim, number of channels to num , x dim, y dim, z dim

So mention X, (3, 0, 1, 2) is incorrect

Instructions before grade cell mentions

when taking subset of the label ‘y’ excludes the background class, remember which dimension contains the ‘num_classes’ channel after re-ordering the axes

So the code is not asking you the order of channels (0, 1, 2) but only wants you mention first the number of channels so it is 3 and 0 as the next code line requires you exclude the background classes and the last dimension of array at index 0 contains labels to identify when vocel is background (value of 1) or not a background(value of 0)

so in the next code line this 0 dimension get excluded.

Hope this make you understand why it is mentioned this way.

Don’t worry about clearing an assignment, you will always clear the assignment today or tomorrow but understanding the codes are more important.

Regards
DP

1 Like

Hi @Deepti_Prasad
I seem to have a similar issue. How can I reset the Homework to its original form, without any of my changes?

@khichi

I have responded on your created topic post.