-
-
Save AMZzee/43e29ca65ab3ca95b7d18c705c882550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_finetune_model(base_model, dropout, fc_layers, num_classes): | |
for layer in base_model.layers: | |
layer.trainable = False | |
x = base_model.output | |
x = GlobalAveragePooling2D()(x) | |
for fc in fc_layers: | |
# New FC layer, random init | |
x = Dense(fc, activation='relu')(x) | |
x = Dropout(dropout)(x) | |
# New softmax layer | |
predictions = Dense(num_classes, activation='softmax')(x) | |
finetune_model = Model(inputs=base_model.input, outputs=predictions) | |
return finetune_model | |
FC_LAYERS = [100, 50] | |
dropout = 0.5 | |
finetune_model = build_finetune_model(base_model, | |
dropout=dropout, | |
fc_layers=FC_LAYERS, | |
num_classes=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I get the TypeError: Inputs to a layer should be tensors. Got: <keras.layers.pooling.GlobalAveragePooling2D object at 0x0000022F5F9FA220>
Do you have any idea why?