Week2 - Assignment 2 error

Hi,

I am working on solving assignment 2. Cannot resolve this error. Appreciate some guidance on how to fix this issue.

{moderator edit - solution code removed}

When you get a syntax error at the beginning of a line like that, it usually means the error is on the previous line. You can see from the green highlighted parens in the “cost =” line that you are missing a close paren on that line. The open paren before the np.sum is not matched.

When you can’t find a python syntax error, it probably means you are looking in the wrong place. :nerd_face:

duh, that fixed it. Now, need to figure out the next issue. Thanks for your help.

Hi,

Running into matrix dimension error. Cannot figure out what am i missing here.

How can I get matrix to be of shape (1,3)? It seems matrix dimension mismatch is causing dw to not match in dimension.

{moderator edit - solution code removed}

The way you are calculating A is incorrect. The math formula is:

A = sigmoid(Z)

It should end up being the same shape as Z and Y, right?

Note that we aren’t suppose to publicly post solution code here on the forums, even if it’s incorrect. :laughing: Please start by just showing us the errors you are getting and we can usually work from that. If we can’t figure it out from there, there are private ways to share code through DMs. No real harm is done here, since I can just edit your post to remove the source code.

oh so the below formula means sigmoid of z. I thought it was two separate variables with multiplication in it. I wish there is a variable description somewhere.

image

Yes, the Greek letter \sigma (lower case sigma) is an alternate way to name the sigmoid function when you are writing math formulas. Of course Greek letters aren’t part of python syntax, so when we switch to writing code we have to spell it out as sigmoid.

I refreshed my memory and Professor Ng did use that notation in the lectures. Here’s time offset 4:00 into the Week 2 lecture titled “Logistic Regression” where he introduces the algorithm (I added some highlights):

It is also used in the first Week 2 assignment about Python Basics with Numpy:

And it also appears in the Logistic Regression assignment, although it’s a bit more subtle (highlights added):

my bad should have referred to notes again.