【Wk2 Ex1- Residual Networks】 Batch normalization:syntax error

Location:
Week2 Assignment
Residual Networks
Exercise 1 - 【identity_block】

Error :
For the exercise part, I wrote

【X = BatchNormalization(axis = 3)(X, training = training) 】

exactly the same as written in the first component already implemented for me.

If the implmentation of the 1st component is correct , why am l getting this error:


File “”, line 34
X = BatchNormalization(axis = 3)(X, training = training)
^
SyntaxError: invalid syntax


The batch normalization for 2nd and 3rd compenent serves the same function as that of 1st component, that’s why l wrote the exact same code.

Could anyone answer my questions? Thx a lot:)

I assume you didn’t actually put square brackets around that line of code, although I confess to being mystified by what value you think those add to your post.

You are right that you should be able to literally copy the BatchNorm line from the first block of template code. But note that when you get a syntax error right at the beginning of a line like that, it usually means there is something wrong (incomplete) about the previous line. Make sure you properly terminated or completed the previous line.

1 Like

Hi Paul,

Problem solved!

The previous line was indeed incorrect and thus triggers the error.

Thx a lot :slight_smile:

BTW, l added the square bracket just to increase readibility.

Perhaps just using the same format as the error post might be a better idea huh?

1 Like

That’s great to hear that you found the solution! Yes, the best way to include code is to use the “</>” tool to format it. That way you get to see it “as it is”.

Cheers,
Paul

1 Like