[Week 2] alpaca_model

I am having the following error, but I don’t know what is wrong.

ValueError Traceback (most recent call last)
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)
—> 26 x = data_augmentation(inputs)

ValueError: Input 0 of layer sequential_3 is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [None, 160, 160]

This is my function extraction
def alpaca_model(image_shape=IMG_SIZE, data_augmentation=data_augmenter()):
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 = tf.keras.Input(shape=image_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(x)

Refer this question: C4 - Week 2 - Transfer learning with MobileNet_v1

Thank you very much. I finally completed the assignment.


it’s no longer work, can you post another hint?