Week 3 - Programming Assignment - Grading question

Hi, so I have been able to get this assignment to run all the way through (seemingly successfully, as I get the expected output results)-- But for some reason it is not giving me 100% credit (Not that I am totally complaining, I got an 88-- However it would be helpful to know how to troubleshoot such issues in the future).

I went back and checked the results of each section, and find ‘All tests passed!’ for each. Unfortunately the grader feedback provides no helpful info as to what cell it is finding problems with. It only states: “Tests failed on 1 cell(s)! These tests could be hidden. Please check your submission.”

What does that mean, that the test could be ‘hidden’ ?

Of the top of my head, the only thing I can think of is:

In the ‘cost’ function, I ignored the suggestion (because it didn’t seem to be needed to me from a programming standpoint) to break the cost evaluation into two steps (i.e. Logprobs =, cost = … I did everything on the cost = line). Second, though it passes the test, under nn_model, I don’t see anything like ‘Expected results’, I just see:

[[2.12532345e-05]]
[[2.12510915e-05]]
[[2.12489489e-05]]
[[2.12468068e-05]]
[[2.12446651e-05]]
[[2.12425238e-05]]
[[2.1240383e-05]]
[[2.12382426e-05]]
[[2.12361026e-05]]
[[2.1233963e-05]]
[[2.12318239e-05]]
All tests passed!

But the print() output would be due to code we didn’t need to (nor did I) touch. Any thoughts ?

Thanks,
-Anthony

It’s a good idea if you include a screen capture image that shows the issue you’re asking about. This gives better context than you telling us what you saw on the screen.

Generally it doesn’t matter how you implement a function - the grader only looks at the output of a function - not the code itself.

But be very careful about redefining anything about the inputs and outputs of a function. That will certainly break the grader.

Also be very careful about using any global variables inside a function. That’s typically a bad idea.

The grader uses different tests than are in the notebook. Passing the tests in the notebook doesn’t prove your code is perfect.

Some of the tests in the notebook are trivially easy, and passing them proves very little about your code.

This might mean your code is stuck in a loop, or is running extremely slowly. Be sure you haven’t added any extra print() statements in your code, that can bog down the kernel.

The values you posted above are suspiciously very similar. I think they are coming from a print() statement you might have added.

After nn_model_test() runs, you should see this:

There is more off the bottom of the image that I couldn’t include in one frame.

Dear TMosh,

Thanks for the feedback. I will make sure to include screenshots next time. I just also for one was surprised the grader didn’t relate which function was failing a test because then it can be like looking for a needle in a haystack.

So I went back and combed through the code carefully.

  1. The iterant output I was getting from the nn_model was the result of a print(cost) statement I put into the ‘compute_cost’ function just because I wanted to see what it looked like and then forgot about. Obviously run through numerous iterations it percolated enmasse. So I removed that.

  2. Second issue I was having is that I forgot about the note in the instructions for ‘layer_sizes’ that we should hard code ‘n_h = 4’-- but *only for exercise 2. I mean ‘nn_model’ is provided with ‘n_h’ as an argument, so you don’t want to override it with the results of ‘layer_sizes’.

I didn’t notice that code provided in ‘nn_model’ provides already a procedure to call ‘layer_sizes’ and get only the parms we want. I was trying to call it myself and screwing things up.

After these changes, and on my second submission, I recieved 100%.

Thanks for your assistance.

Best,
-Anthony

1 Like

Thanks for your report.

I agree, the grader’s diagnostics could be a lot better.

Realized my ‘needle in a haystack’ comment was too strong. I mean though this subject is novel to me the code involved, honestly, is not amazingly challenging (which is okay, why over complicate things ?)-- Just I guess it is also a new experience for me in that, even if it is entirely my own program, I know what goes in-- And what the results out will be. Typically, that’s how you ‘debug’ no ?

I mean a lot of people still will say NN’s are a ‘black box’ (and I can start to see that), just here with the grader, it is as if your code is now in a black box.

Anyways, it is okay-- Teaching me to think in a new way.