admin管理员组文章数量:1131176
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
本文标签: pythonkeras get outputlayer of model based on Xception netStack Overflow
版权声明:本文标题:python - keras get outputlayer of model based on Xception net - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736732429a1950072.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论