Course 1, Week 2, Exercise 8, logistic_regression_model wrong even though all the tests passed

Well, that was just a suggestion of one common type of mistake that causes mismatching dimensions. That may not be the mistake you have made.

I checked and the shape of the X value in that test case is 2 x 3, so your W1 should be of shape 4 x 2. So why did it turn out to be 4 x 5? If your previous functions like initialize_parameters and forward_propagation etc passed the unit tests, then the bug must be in nn_model. Either you are passing the wrong values to the initialize routine. Try adding some print statements to show the shapes of your W1 and W2 values in the main loop before you call forward propagation.

Something is clearly wrong. Now your job is to figure out what it is.

Actually here’s a theory: maybe you hard-coded the return values from the layer_sizes function, instead of using the “shapes” of the input variables. If you just always return 5 for n_x, that still passes the test case in the notebook, but it’s a fundamental mistake and will cause havoc later when you actually use the layer_sizes function.