【发布时间】:2019-08-16 08:26:42
【问题描述】:
我有以下型号(例如)
input_img = Input(shape=(224,224,1)) # size of the input image
x = Conv2D(64, (3, 3), strides=(1, 1), activation='relu', padding='same')(input_img)
我的自动编码器模型中有好几层这样的层。我对第一层的过滤器特别感兴趣。有 64 个过滤器,每个大小为 3x3。
为了获取过滤器,我尝试使用以下代码:
x.layers[0].get_weights()[0]
但我收到如下错误:
AttributeError Traceback (most recent call last)
<ipython-input-166-96506292d6d7> in <module>()
4 x = Conv2D(64, (3, 3), strides=(1, 1), activation='relu', padding='same')(input_img)
5
----> 6 x.layers[0].get_weights()[0]
AttributeError: 'Tensor' object has no attribute 'layers'
我没有使用顺序模型。在几个这样的层之后,我的模型将使用以下命令形成。
model = Model()
我是 CNN 的新手,我什至不知道 get_weights 函数是否可以帮助我获得过滤器值。如何获取过滤器的值?
【问题讨论】:
标签: python tensorflow conv-neural-network keras-layer autoencoder