首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >提取cnn的输出

提取cnn的输出
EN

Stack Overflow用户
提问于 2019-05-14 20:37:14
回答 1查看 92关注 0票数 0

我已经训练了一个cnn模型来对狗和猫的图像进行分类,它提供了98%的准确率,但我想可视化cnn层的输出,即我的cnn预测它是狗还是猫的特征,如果有什么方法可以可视化cnn的输出?

EN

回答 1

Stack Overflow用户

发布于 2019-05-14 21:05:10

您可以将模型分为两个模型:

以前的型号:

代码语言:javascript
运行
复制
input = Input(...)

# Your Layers
output = Dense(1)
old_model = Model(inputs=[input], output)

新模型:

代码语言:javascript
运行
复制
input = Input(...)

#Add the first layers and the CNN here
cnn_layer = Conv2D(...)
feature_extraction_model = Model(inputs=[input], outputs=cnn_layer)

input_cnn = Input(...) # The shape of your CNN output

# Add the classification layer here
output = Dense(1)

classifier_model = Model(inputs=[input_cnn], outputs=output)

现在,您将新模型定义为:feature_extraction_modelclassifier_model的组合

代码语言:javascript
运行
复制
new_model = Model(inputs=[input], outputs=classifier_model(input_cnn))

# Train the model
new_model.fit(x, y)

现在,您可以访问CNNlayer post培训:

代码语言:javascript
运行
复制
cnn_output = feature_extraction_model.predict(x)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56130678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档