如何使用python模型模型提取特征?

时间:2020-03-13 19:29:15

标签: python machine-learning model classification layer

我训练了一个进行对象分类的python模型。然后,我想将此模型用作特征提取器,但我不知道图层的所有名称。代码是

True

我使用模型摘要功能获取模型的图层名称,但输出为

base_model = load_model('models/deepfake-detection-model.h5')
base_model.summary()

for layer in base_model.layers:
    print(layer.name)


#extract = Model(model.inputs, layer_n) # Dense(128,...)

data= cv2.imread('dataset/real/eudeqjhdfd_4.png')

#features = extract.predict(data)
for l in base_model.layers:
    print (l.output_shape)

layer_n=inception_resnet_v2
model = Model(inputs=base_model.input, outputs=base_model.get_layer(layer_n).output)

有人可以告诉我如何知道模型层的名称并将其用作特征提取技术吗?

0 个答案:

没有答案