I’ve tried to reach out to coursera support but with no response so far.
I am quite sure I should have 100% on all the exercises as my results match what the unit tests expects.
However I get a strange error and incorrect results 66% instead of 100%.
I can’t seem to get this to work or get any feedback on why except for the below error message from Grading logs.
It’s is not clear to me what gives.
Perhaps someone could clarify what’s wrong and why unit tests don’t behave as expected.
Code Cell UNQ_C2: Unexpected error (TypeError(“ufunc ‘isfinite’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’”)) occurred during function check. We expected function verify to return verify test 1 failed. Please check that this function is defined properly.
Yes. I pasted exactly that error. in the description.
Perhaps that’s not clear? The screen shot will be exactly the same message. There is no extra information other than this, which is part of the problem, I guess…
Just passing one set of tests does not prove your code is fully correct. E.g. it is usually possible to write your code in a non-general way that is hard-coded in some fashion to match the tests in the notebook. Or perhaps it doesn’t handle all the possible types of inputs.
The specific error message sounds like you probably have a “divide by zero” problem, but this is the verify function and there aren’t really that many “moving parts” here. It must be that the datatype of one of your variables is incorrect. Actually looking again at this routine to refresh my memory, note that you have two choices: you can implement it all in numpy or you can implement it in TF. But (of course) the point is that you need to be consistent one way or the other. Feeding TF tensors to a numpy call or numpy arrays to a TF call will not end well, although I wouldn’t expect that particular “isfinite” error message in that case.
If those suggestions aren’t helpful, then the better thing is just to look at your code. We can’t do that in a public thread, but I’ll send you a DM about how to proceed with that.
Well, like I said TMosh: The screenshot has exactly the same error message. The code itself holds my entire solution. I assume you don’t mean I should screen shoot, right? I take you mean screenshot of the error? The screen capture would just have the same info as the text except without the ability for you to copy paste …
Of course hardcoding to pass unit tests not correct is obviously not what I’m doing.
There are 3 parts. The first one specifies to use TF. The second part explicitly tells to use numpy. I have just followed the spec as stated. The division by zero should not occur from what I can see in my code. Unless there is a bug in the grading software?
I’m not sure where feeding of numpy calls would occur. Is there is such a flow then it would seem this is done by the testing software and then the spec is logically inconsistent. Since it tells you to use TF in UNQ_C1 and numpy in UNQ_C2. Note UNQ_C1 and UNQ_C3 are correct. it is just the UNQ_C2, “verify(image_path, identity, database, model)” that is messing around with me…
To close the loop on the public thread, Christopher’s code was correct, but there was apparently something inconsistent in the runtime state of the notebook. It graded fine when I tried it. So Christopher did this sequence:
Kernel -> Restart and Clear Output
Cell -> Run All
Save
Submit
and that worked. Note that the “Cell → Run All” is optional there: the grader does not depend on seeing the generated output in the notebook. It only needs to call your functions.