C4W2A2 Grader deducts marks despite great accuracy

Hi,

I can’t figure out what’s wrong with my code, but the grader seems to give me only 66% marks. Below is the grader output.

In Jupyter, I got “all tests passes” for all cells. The training and validation set loss / accuracy vs epoch looks great.

Please help to provide me feedback that I can understand and use to improve my understanding.

Code Cell UNQ_C1: Function ‘data_augmenter’ is correct.
Code Cell UNQ_C2: Unexpected error (ValueError(‘The first argument to Layer.call must always be passed.’)) occurred during function check. We expected function alpaca_model to return alpaca_model test 1 failed. Please check that this function is defined properly.
Code Cell UNQ_C3: The value of your variable ‘loss_function’ is correct.
Code Cell UNQ_C3: The value of your variable ‘optimizer’ is correct.
Code Cell UNQ_C3: The value of your variable ‘metrics’ is correct.
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.

1 Like

There is something wrong with your definition of the alpaca_model function. Are you sure everything runs correctly in the notebook? Also are you sure you did a “Save” before you submitted to the grader to make sure the grader is seeing the same code you are?

Please show us the output of running the test cell for the alpaca_model function. Here’s what I see:

All tests passed!
['InputLayer', [(None, 160, 160, 3)], 0]
['Sequential', (None, 160, 160, 3), 0]
['TensorFlowOpLayer', [(None, 160, 160, 3)], 0]
['TensorFlowOpLayer', [(None, 160, 160, 3)], 0]
['Functional', (None, 5, 5, 1280), 2257984]
['GlobalAveragePooling2D', (None, 1280), 0]
['Dropout', (None, 1280), 0, 0.2]
['Dense', (None, 1), 1281, 'linear']
1 Like

Thanks for your response. Yes, everything seems to run correct in the notebook. I tried ‘save and checkpoint’ and then re-submitted my assignment but got the same grader error. Below is the test cell output for alpaca_model function.

1 Like

I was able to debug this by checking out a fresh copy of notebook and copying my code from old notebook to fresh one. By doing this, I was able to get the same error that grader showed, and thus I was able to fix it. Problem was that I was invoking data_augmentation as:
data_augmentation()(inputs)
instead of:
data_augmentation(inputs)

After fixing this, I’m able to get 100% score from grader. I have no idea why in my older notebook this error was not flagged and all tests had passed.

1 Like

When I tried your code:
x = data_augmentation()(inputs)
… I got an error message when I ran the cell in the notebook. I did not have to run the grader to see this error.

Hi Tom,

Thanks for your response. Yes, as I already mentioned in my earlier reply on this topic, after stating a fresh, I was able to ‘obtain’ the same error in the notebook with my erroneous code and subsequently debug the problem and find the solution. Btw, this was the same error that the grader showed in my first attempt at the time when I created this topic. What is not clear is, why at that time in my first attempt, the notebook did NOT show the error and “all tests passed”.

I still have my first attempt notebook that fails to recognize the error saved in my lab workspace. The file name is “Transfer_learning_with_MobileNet_v1_OLD.ipynb”. Notice “OLD” in the filename. I don’t know if you can access my workspace, but if you can, will be great if you could help me understand what I did wrong in my first attempt.

Thank you,
Manav.

1 Like

Please check your personal messages for instructions.

Got it, and replied as instructed in the personal message.

1 Like

Comparing my notebook vs. your “OLD” notebook, I found this difference doing a character-by-character file comparison:

Thanks Tom. I see. That must have messed up my code. However, it’s still not clear how this change you pointed out could cause the lab notebook to pass all tests but the grader to catch the error. I guess it’s not easy to figure out now.
Btw, when you run my OLD code in your notebook, does it error out, or pass all tests?

Your OLD code passes all the tests in the notebook. But I did not try to submit it for grading.

Yeah, that’s the hard part… when I submitted it for grading, the grader gave the exact same error that you got when you tried the following erroneous line in your code:
x = data_augmentation()(inputs)

Your OLD notebook has another difference I did not notice yesterday.
You have additional metadata that my notebook does not contain.

Do you have an idea where this metadata came from?

And just for completeness, OLD also has this difference.

OK, so I think I understand the issue now.

Your OLD notebook has two offsetting mistakes. Both of these mistakes together are OK when the notebook is run by itself. But the grader does additional checks, and these issues either:

  • make the grader crash with “data_augmenter() takes 0 positional arguments”.
    or…
  • gives a runtime error “First argument to layer call must be passed”.

Here are the two issues:

  • You modified the call to alpaca_model() in a way that you shouldn’t have. That cell does not have a YOUR CODE HERE banner, so it should not have been changed.
    You wrote:
    model2 = alpaca_model(IMG_SIZE, data_augmenter)
    but the correct code is this:
    model2 = alpaca_model(IMG_SIZE, data_augmentation)

  • So this error creates a problem in the alpaca_model() function, because you wrote this incorrect code:
    x = data_augmentation()(inputs)
    when it should be this:
    x = data_augmentation(inputs)

If both of these mistakes are corrected in the OLD notebook, then it will pass the grader 100%.

Tom,

Thanks for your valuable time and helping to get to the bottom of this. It makes sense now!

Regards,
Manav.

P.S.: I have no idea where that extra meta data came from, and what it means.