Skip to content

Instantly share code, notes, and snippets.

@himanshurawlani
Created March 21, 2019 13:03
Show Gist options
  • Save himanshurawlani/65df0462fa4f7dcec8e3faafe42a4b37 to your computer and use it in GitHub Desktop.
Save himanshurawlani/65df0462fa4f7dcec8e3faafe42a4b37 to your computer and use it in GitHub Desktop.
Using Keras's Sequential API to add classification head on top of InceptionV3 base model.
def build_model():
# Using Sequential API to stack up the layers
model = keras.Sequential([
base_model,
keras.layers.GlobalAveragePooling2D(),
keras.layers.Dense(metadata.features['label'].num_classes,
activation='softmax')
])
# Compile the model to configure training parameters
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
return model
inception_model = build_model()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment