在Keras中是否可以看到Conv2D层之后的输出 [英] Is it possible to see the output after Conv2D layer in Keras

查看:84
本文介绍了在Keras中是否可以看到Conv2D层之后的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施CNN时理解Keras的每一层.

I am trying to understand each layer of Keras while implementing CNN.

在Conv2D层中,我了解到它会根据各种特征图值创建不同的卷积层.

In Conv2D layer i understand that it creates different convolution layer depending on various feature map values.

现在,我的问题是

  1. 我可以看到应用于输入图像以获取卷积层的不同特征图矩阵吗?
  2. 我能看到Conv2D步骤完成后生成的矩阵的值吗?

预先感谢

推荐答案

您可以通过以下方式获取特定卷积层的输出:

You can get the output of a certain convolutional layer in this way:

import keras.backend as K

func = K.function([model.get_layer('input').input], model.get_layer('conv').output)
conv_output = func([numpy_input])  # numpy array

其中,"input"和"conv"表示输入层和卷积层的名称.您可以像这样获得某一层的权重:

where 'input' and 'conv' denote the names of your input layer and convolutional layer. And you can get the weights of a certain layer like this:

conv_weights = model.get_layer('conv').get_weights()  # numpy array

这篇关于在Keras中是否可以看到Conv2D层之后的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆