My code error

When creating a post, please add:

  • Week # must be added in the tags option of the post.
  • Link to the classroom item you are referring to:
  • Description (include relevant info but please do not post solution code or your entire notebook)

{moderator edit - solution code removed}

why my code is error?
File “”, line 34
cost = (1/m)*np.sum(np.array(Y)*np.log(np.array(A))+(1-np.array(Y))*np.log(1-np.array(A)))
^
SyntaxError: invalid syntax

this is error code

Hmmm.

Notice that you’re working harder than you need to by rewriting the logic of the sigmoid function by hand. You just built that as a function, so the point of that was that you can then call it when you need sigmoid.

But notice that the parentheses do not match on that line: there are 5 open parens and only 4 close parens. That’s why it throws that syntax error on the next line. If you can’t find a syntax error in python, it usually means you are looking in the wrong place. :nerd_face:

If it throws an error at the beginning of a line, it usually means there is something incomplete about the previous line.

Also note that you don’t need to apply np.array to something that is already a numpy array … It does no harm, but it’s a waste of effort. Why write more code than you need to?