Week 2 - Assignment 2

UNQ_C2

GRADED FUNCTION

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

I am getting errors as -

Test failed
Expected value

[‘Sequential’, (None, 160, 160, 3), 0]

does not match the input value:

[‘TensorFlowOpLayer’, [(None, 160, 160, 3)], 0]

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

~/work/W2A2/test_utils.py in comparator(learner, instructor)
19 “\n\n does not match the input value: \n\n”,
20 colored(f"{a}", “red”))
—> 21 raise AssertionError(“Error in test”)
22 print(colored(“All tests passed!”, “green”))
23

AssertionError: Error in test

Can someone please, help me find my mistake?

The problem is in your MobileNetV2 layer. You’ve left a “None” statement there instead of specifying the input shape.

I changed that to this:

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

Still getting the same error.

Data argument of preprocess input is wrong

Why it should be x? and not inputs?

Each output is the input to the next layer.
You got ‘x’ from data_augmentation() of the inputs.
Now you use ‘x’ in the next layer.
Then the later layers modify x in-place.

Thank’s for the explanation. It’s clear now.