Getting an error in module 4 and assignment 2 in week2 in ResNet50 function

Hello, I am running below code but getting the bellow error after executing the code.

“ValueError: The name “res_branch2a” is used 12 times in the model. All layer names should be unique.”

UNQ_C3

GRADED FUNCTION: ResNet50

def ResNet50(input_shape = (64, 64, 3), classes = 6):
“”"
Stage-wise implementation of the architecture of the popular ResNet50:
CONV2D → BATCHNORM → RELU → MAXPOOL → CONVBLOCK → IDBLOCK2 → CONVBLOCK → IDBLOCK3
→ CONVBLOCK → IDBLOCK5 → CONVBLOCK → IDBLOCK2 → AVGPOOL → FLATTEN → DENSE

Arguments:
input_shape -- shape of the images of the dataset
classes -- integer, number of classes

Returns:
model -- a Model() instance in Keras
"""

# Define the input as a tensor with shape input_shape
X_input = Input(input_shape)


# Zero-Padding
X = ZeroPadding2D((3, 3))(X_input)

# Stage 1
X = Conv2D(64, (7, 7), strides = (2, 2), kernel_initializer = glorot_uniform(seed=0))(X)
X = BatchNormalization(axis = 3)(X)
X = Activation('relu')(X)
X = MaxPooling2D((3, 3), strides=(2, 2))(X)

# 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 ###
# The convolutional block uses three set of filters of size [128,128,512], "f" is 3, "s" is 2 and the block is "a".
# The 3 identity blocks use three set of filters of size [128,128,512], "f" is 3 and the blocks are "b", "c" and "d".

# Stage 3 (≈4 lines)
X = convolutional_block(X, f = 3, filters = [128, 128, 512], s = 2)
X = identity_block(X, 3, [128, 128, 512])
X = identity_block(X, 3, [128, 128, 512])
X = identity_block(X, 3, [128, 128, 512])

# Stage 4 (≈6 lines)
X = convolutional_block(X, f = 3, filters = [256, 256, 1024],  s = 2)
X = identity_block(X, 3, [256, 256, 1024])
X = identity_block(X, 3, [256, 256, 1024])
X = identity_block(X, 3, [256, 256, 1024])
X = identity_block(X, 3, [256, 256, 1024])
X = identity_block(X, 3, [256, 256, 1024])

# Stage 5 (≈3 lines)
X = convolutional_block(X, f = 3, filters = [512, 512, 2048], s = 2)
X = identity_block(X, 3, [512, 512, 2048])
X = identity_block(X, 3, [512, 512, 2048])

# AVGPOOL (≈1 line). Use "X = AveragePooling2D(...)(X)"
X = AveragePooling2D(pool_size=(2, 2), name='avg_pool')(X)

### 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

any help pls?

The use of “name” strings for the various layers was only used in the previous version of the course. That was eliminated when they upgraded the course to TF2 in April of 2021. So it looks like perhaps you are still in the old version of the course or maybe have imported your notebook from the old version of the course. It is recommended that you get a fresh copy of the assignment (see the relevant topic on the FAQ Thread) and then go through carefully and compare your code to what the new notebook is asking you to do.

Also note that you filed this question under “General Discussion” which may be why it took a while to get noticed. You’ll have better luck if you post under the correct course. I’ve moved this for you to DLS Course 4.