Skip to content

Instantly share code, notes, and snippets.

@d-misra

d-misra/model.py Secret

Last active Jan 17, 2021
Embed
What would you like to do?
VGG16 model for clustering
from keras.models import load_model, Model
from keras.applications.vgg16 import VGG16, preprocess_input
def setup_model(layer='fc2'):
base_model = VGG16(weights='imagenet', include_top=True)
# base_model.summary():
# ....
# block5_conv4 (Conv2D) (None, 15, 15, 512) 2359808
# _________________________________________________________________
# block5_pool (MaxPooling2D) (None, 7, 7, 512) 0
# _________________________________________________________________
# flatten (Flatten) (None, 25088) 0
# _________________________________________________________________
# fc1 (Dense) (None, 4096) 102764544
# _________________________________________________________________
# fc2 (Dense) (None, 4096) 16781312
# _________________________________________________________________
# predictions (Dense) (None, 1000) 4097000
#
model = Model(inputs=base_model.input,
outputs=base_model.get_layer(layer).output)
return model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment