Hello.
I don’t know where is incorrect. below is my code.
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
‘’’
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=input_shape)
# apply data augmentation to the inputs
x = data_augmentation
# data preprocessing using the same weights the model was trained on
x = preprocess_input()
# set training to False to avoid keeping track of statistics in the batch norm layer
base_model.training = False
# Add the new Binary classification layers
# use global avg pooling to summarize the info in each channel
x = tf.keras.layers.GlobalAveragePooling2D()
#include dropout with probability of 0.2 to avoid overfitting
x = tf.keras.layers.Dropout(rate = 0.2)
# create a prediction layer with one neuron (as a classifier only needs one)
prediction_layer = tf.keras.layers.Dense(1, activation='linear')
# YOUR CODE STARTS HERE
prediction_layer = tf.keras.layers.Dense(1, activation=‘linear’)
# YOUR CODE ENDS HERE
outputs = prediction_layer(x)
model = tf.keras.Model(inputs, outputs)
return model