CNN预训练模型特征提取

时间:2020-10-24 07:32:00

标签: deep-learning feature-extraction cnn

全局平均值是用于特征提取并进一步传递给另一个模型的最佳选择还是fc1层? 提取特征或重新训练的另一种选择是什么

input_size = (img_size, img_size, 3)
model_name == "xception":
baseModel = Xception(
weights="imagenet",
include_top=False,
input_shape=(img_size, img_size, 3)
)
headModel = baseModel.output
headModel = GlobalAveragePooling2D()(headModel)
headModel = Dense(512, activation="relu", kernel_initializer="he_uniform", name="fc1")(
headModel
)
headModel = Dropout(0.4)(headModel)
predictions = Dense(
2,
activation="softmax",
kernel_initializer="he_uniform")(
headModel
)
model = Model(inputs=baseModel.input, outputs=predictions)
model_l = Model(
inputs=baseModel.input,
outputs=model.get_layer("global_avg").output
)
for layer in baseModel.layers:
layer.trainable = False

0 个答案:

没有答案