Reputation: 7
Good morning, i tried to create a base_model based on xception net by following this tuto 1. the model is trained on cifar10 database and all is well (the model summary is shown in the following image) . i saved the model as .pkl file. i want to eliminate the three final layers named ( global_average_pooling2d, dropout and dense) and add ours as shown in the following code. the problem i did not see the layers (input_layer_1 ,lambda ,sequential ,true_divide and subtract ) (see this figure ).Where did they go? remarque: When i change the layer_name='xception' to an other one example layer_name='global_average_pooling2d' the layers (input_layer_1 ,lambda ,sequential ,true_divide and subtract ) appear in the new model!!! as shown in figure .
with open(base_modelpath, 'rb') as file:
base_model = pickle.load(file)
base_model.summary()
base_model.trainable = False
inputs = tf.keras.Input(shape=(32, 32, 3))
layer_name='xception'
intermediate_layer_model = Model(inputs=base_model.input, outputs=base_model.get_layer(layer_name).output)
x = intermediate_layer_model(inputs, training=False)
x = tf.keras.layers.GlobalAveragePooling2D()(x)
x = tf.keras.layers.Dropout(0.3)(x)
outputs = tf.keras.layers.Dense(1, activation=('softmax'))(x)
model = tf.keras.Model(inputs, outputs)
#Check the architecture of the final model
model.summary()
thanks an advance
Upvotes: -2
Views: 42