首页 > 解决方案 > 寻找 keras inceptionresnetv2 的图层名称

问题描述

真的不知道我在做什么,按照本教程处理 deepdream 图像https://www.youtube.com/watch?v=Wkh72OKmcKI

试图从这里将基本模型数据集更改为任何,https: //keras.io/api/applications/#models-for-image-classification-with-weights-trained-on-imagenet 目前尤其是 InceptionResNetV2。InceptionV3 使用“mixed0”到“mixed10”,而前一个数据集显然使用了不同的命名系统。

必须更改此部分

# Maximize the activations of these layers
names = ['mixed3', 'mixed5']
layers = [base_model.get_layer(name).output for name in names]

# Create the feature extraction model
dream_model = tf.keras.Model(inputs=base_model.input, outputs=layers)

我收到一个错误“没有这样的层:mixed3”

所以是的,只是想弄清楚如何获取该数据集中的图层以及其他图层的名称

标签: pythontensorflowkeras

解决方案


您只需输入以下代码即可找出模型架构(包括层名称)。

#Model denotes the Inception model
model.summary()

或者将复杂的关系可视化,

tf.keras.utils.plot_model(model, to_file='model.png')

推荐阅读