Course 1, Week 3, Exercise 5 grader/test glitch?

If for number of examples, A2.shape[1] is used instead of m and the cell is run, the notebook displays “All tests passed.” but the grader does not award points (no err msg printed, but X increased by 1 in “Tests failed on X cell(s)!”.)

I would not consider A2.shape[1] wrong, given
Arguments:
A2 – The sigmoid output of the second activation, of shape (1, number of examples)

It should be legitimate to use A2.shape[1] in place of m. But they gave you the code to set m to Y.shape[1], right? Why make it more complicated than it needs to be?

There must be something else wrong with your code that causes it to fail the grader.

to be clear, when I use m the grader accepts the solution, when I change to A2.shape[1] and submit again the grader rejects it, when I change back to m and submit again, the grader accepts it again.

Interesting. There may be a problem here, but it seems like you are going out of your way to make things complicated. If you are talking about the actual cost implementation, it’s a lot easier to write 1/m then 1/A2.shape[1].

Just to be clear: you are talking about compute_cost(), right?

on that I agree. Just wasn’t sure what the global was and thought just make do with the locals. yes, it is about compute_cost()

What “global” are you referring to? We only deal with A2 and Y here, which are parameters to the function, right?

m is not a global: it is defined by the template code that they gave you and uses Y.shape[1]. Well, unless you deleted that line. In that case, you should get a clean copy and compare. There is a procedure for that on the FAQ Thread.

ah, overlooked the line
m = Y.shape[1] # number of examples
so I got m from somewhere else

Thank you by the way!