Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Created April 29, 2020 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayakpaul/55ad8e3e4331b580c079d7d771038acd to your computer and use it in GitHub Desktop.
Save sayakpaul/55ad8e3e4331b580c079d7d771038acd to your computer and use it in GitHub Desktop.
# Load the MobileNetV2 model but exclude the classification layers
EXTRACTOR = MobileNetV2(weights='imagenet', include_top=False,
input_shape=(224, 224, 3))
# We are fine-tuning
EXTRACTOR.trainable = True
# Construct the head of the model that will be placed on top of the
# the base model
class_head = EXTRACTOR.output
class_head = GlobalAveragePooling2D()(class_head)
class_head = Dense(512, activation="relu")(class_head)
class_head = Dropout(0.5)(class_head)
class_head = Dense(1)(class_head)
# Create the new model
pet_classifier = Model(inputs=EXTRACTOR.input, outputs=class_head)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment