Skip to content Skip to sidebar Skip to footer

Pre-training Keras Xception And Inceptionv3 Models

I'm trying to do a simple binary classification problem using Keras and its pre-built ImageNet CNN architecture. For VGG16, I took the following approach, vgg16_model = keras.appli

Solution 1:

Your code fails because InceptionV3 and Xception are not Sequential models (i.e., they contain "branches"). So you can't just add the layers into a Sequential container.

Now since the top layers of both InceptionV3 and Xception consist of a GlobalAveragePooling2D layer and the final Dense(1000) layer,

if include_top:
    x = GlobalAveragePooling2D(name='avg_pool')(x)
    x = Dense(classes, activation='softmax', name='predictions')(x)

if you want to remove the final dense layer, you can just set include_top=False plus pooling='avg' when creating these models.

base_model = InceptionV3(include_top=False, pooling='avg')
for layer in base_model.layers:
    layer.trainable = False
output = Dense(2, activation='softmax')(base_model.output)
model = Model(base_model.input, output)

Post a Comment for "Pre-training Keras Xception And Inceptionv3 Models"