Invalid Syntax error

parameters = {“W1”: W1,
“b1”: b1,
“W2”: W2,
“b2”: b2}

this is showing invalid syntax, syntax error

This part is provided to me and i just open the jupyter notebook and only type 4 lines to initialize w,b and run that part this is occurring in week 4 assignment.

Hi @Prabhanshu, you need to check the equations in the above four lines of code. Look for the syntax error in parenthesis, equal signs, if any.

1 Like

Check the line before that line to make sure you are not missing a close paren. The other thing to be careful of is that indentation is part of the syntax in python. You can’t just line things up the way you like: you have to know and follow the rules. If you accidentally changed any of the indentation, that can cause this type of problem. Although typically the parser will say “indentation” in the error message, if that’s what it is complaining about.

1 Like

Exactly: you were missing the close paren on the previous line with the np.zeros call.

This might seem weird, but you have to think like the parser: it knows it’s missing the close paren, so it keeps looking forward onto the next line hoping to find the completion. But then when it sees something that conflicts with what it is expecting, that’s where it throws the error. That’s why the error message shows up after the point of the real error. But you could view this as just the same as when you pass a bad parameter down to a subroutine: the error gets thrown in perfectly correct code in the subroutine and you have to track backwards up the call stack to find the actual error. This is all part of debugging. :nerd_face:

1 Like

Thank You Sir.
Your information is very helpful