---> 12 comparator(summary(model2), alpaca_summary)

Can you please help me sorting my error



def alpaca_model(image_shape=IMG_SIZE, data_augmentation=data_augmenter()):
‘’’ Define a tf.keras model for binary classification out of the MobileNetV2 model
image_shape – Image width and height
data_augmentation – data augmentation function

input_shape = image_shape + (3,)


base_model = tf.keras.applications.MobileNetV2(input_shape=input_shape,
                                               include_top=False, # <== Important!!!!
                                               weights='imagenet') # From imageNet

# freeze the base model by making it non trainable
base_model.trainable = False

# create the input layer (Same as the imageNetv2 input size)
inputs = tfl.Input(shape=input_shape) 

# apply data augmentation to the inputs
x = data_augmentation(inputs)

# data preprocessing using the same weights the model was trained on
x = preprocess_input(inputs)

# set training to False to avoid keeping track of statistics in the batch norm layer
x = base_model(x, training=False)

# add the new Binary classification layers
# use global avg pooling to summarize the info in each channel
x = tfl.GlobalAveragePooling2D()(x)
# include dropout with probability of 0.2 to avoid overfitting
x = tfl.Dropout(0.2)(x)
# use a prediction layer with one neuron (as a binary classifier only needs one)
outputs = tfl.Dense(1)(x)


model = tf.keras.Model(inputs, outputs)

return model

AssertionError Traceback (most recent call last)
10 [‘Dense’, (None, 1), 1281, ‘linear’]] #linear is the default activation
—> 12 comparator(summary(model2), alpaca_summary)
14 for layer in summary(model2):

~/work/W2A2/test_utils.py in comparator(learner, instructor)
14 def comparator(learner, instructor):
15 if len(learner) != len(instructor):
—> 16 raise AssertionError(f"The number of layers in the model is incorrect. Expected: {len(instructor)} Found: {len(learner)}")
17 for a, b in zip(learner, instructor):
18 if tuple(a) != tuple(b):

AssertionError: The number of layers in the model is incorrect. Expected: 8 Found: 7

Hi @Sanchay12,

I have moved this post to the DLS Course 4 category as other learners taking the same course might benefit from this.

Kindly make sure if you have any course-specific queries, explore the specialization category and post in the relevant course subcategory as course-specific mentors are actively answering the queries there. The General Discussions category is not monitored by our mentors.

If you are unclear about how to use Discourse, we have made this guide for our learners. I believe that reading this will help you out posting in the appropriate categories next time.

Happy Learning!!

You should not post your code on the Forum, unless a mentor asks to see it.

I am sorry sir i will keep that in mind