Coding help needed for deep learning, C4_W3 resnet Jupyrer notebook, exercise 3, stage 2

Hi: I am having a problem with C4_W2 - the resnet Jupyter notebook - in exercise 3
I have completed the other 2 exercises in this Notebook successfully, and I have entered all the required code for exercise. Curiously I am getting a syntax error early in exercise which I believe reference code in Stage 2 of Exercise 3 which was ALREADY entered by the program - I did not put or edit any code in Stage 2. Are we supposed to edit this code in State 2? Or is the error not referencing the code in Stage 2
Below is the error message. I can send the code if you need it.
Thanks for any help you might provide which has been helpful in the past

Input In [7]
X = identity_block(X, 3, [64, 64, 256])
^
SyntaxError: invalid syntax

1 Like

Syntax errors are usually in the lines previous to the line where the error is detected. This is because the error is marked at the point that the parser gave up on trying to understand the code.

So some of the code you’ve added to the notebook just before that line is causing a syntax error.

1 Like

Thanks for the response. I have included the code below starting at stage 2 where I believe the error is occurring in the 2nd line in stage 2. And looking at the line of code just above it, - this STILL looks o.k. - so I don’t know what is causing the syntax error. In addition, ALL of this stage 2 code has been supplied by the program itself, it is not my coding. Am I supposed to alter this?

Thanks for any help you could supply

Stage 2

X = convolutional_block(X, f = 3, filters = [64, 64, 256], s = 1)
X = identity_block(X, 3, [64, 64, 256])
X = identity_block(X, 3, [64, 64, 256])
     
  ### START CODE HERE

# Use the instructions above in order to implement all of the Stages below
# Make sure you don't miss adding any required parameter

## Stage 3 (≈4 lines)
# `convolutional_block` with correct values of `f`, `filters` and `s` for this stage
# X = None

# the 3 `identity_block` with correct values of `f` and `filters` for this stage
# X = None
# X = None
# X = None

# Stage 4 (≈6 lines)
# add `convolutional_block` with correct values of `f`, `filters` and `s` for this stage
# X = None

# the 5 `identity_block` with correct values of `f` and `filters` for this stage
# X = None
# X = None
# X = None
# X = None
# X = None

# Stage 5 (≈3 lines)
# add `convolutional_block` with correct values of `f`, `filters` and `s` for this stage
# X = None

# the 2 `identity_block` with correct values of `f` and `filters` for this stage
# X = None
# X = None

# AVGPOOL (≈1 line). Use "X = AveragePooling2D()(X)"
# X = None

# the 3 `identity_block` with correct values of `f` and `filters` for this stage
# X = None
# X = None
# X = None

# Stage 4 (≈6 lines)
# add `convolutional_block` with correct values of `f`, `filters` and `s` for this stage
# X = None

# the 5 `identity_block` with correct values of `f` and `filters` for this stage
# X = None
# X = None
# X = None
# X = None
# X = None

### END CODE HERE


# output layer
X = Flatten()(X)
X = Dense(classes, activation='softmax', kernel_initializer = glorot_uniform(seed=0))(X)


# Create model
model = Model(inputs = X_input, outputs = X)

return model

Input In [7]
X = identity_block(X, 3, [64, 64, 256])
^
SyntaxError: invalid syntax

1 Like

Perhaps you modified something farther up in the notebook in Stage 1 or higher.

1 Like

You must have accidentally broken that code if you are claiming it is part of the template. I suggest you start again with a clean copy.

What is “Input in [7]” in python?

1 Like