Week 3 practice lab logistic regression course 1 machine learning

how to solve this error

{moderator edit - solution code removed}

Note that you filed this under “General Discussion”. You will have a better chance of getting a quick answer if you post questions under the appropriate category. I used the little “edit pencil” on the title to move it for you to MLS Course 1 Week 3. Hopefully one of the MLS mentors will see it soon and respond.

2 Likes

I’m not an MLS mentor and haven’t taken that yet, but I think I can see the bug. Notice that you get the value of m from the shape of a variable X_train, but that variable is not defined anywhere within that function. So that means you are picking up a global variable that happens to have a different shape than the actual parameters that are passed.

Also please note that in general we’re not supposed to post our source code in public places, even if it has mistakes in it. There are private ways to share source code if the mentors can’t figure out how to help by seeing your error output. It’s fine to post an exception trace, even though that may contain a little bit of source code.

1 Like

The template code for compute_cost() did include this line:
m, n = X.shape

So ‘m’ should have been defined and correct within the function. That’s critical - use the function parameters, not global variables.

1 Like