如何将CNN模型配置保存到文件

时间:2019-02-04 12:09:46

标签: keras deep-learning conv-neural-network

我想将CNN模型配置(内核大小,激活,过滤器等)保存到txt文件。通过使用“摘要”,我只能得到图层的输入,输出和参数,但是我需要更多信息。

我尝试了以下功能:

# large dictionary with all information, but have a lot of noise info
config = model.get_config()
# same dictionary, but converted to string
summaryJson = str(model.to_json())

所有这些解决方案都没有给我最重要的参数。因此,我发现此解决方案似乎可以满足我的所有需求,但不起作用:

from keras_diagram import ascii
summary = asc(model)

但这给了我以下错误:

AttributeError: 'Activation' object has no attribute 'inbound_nodes'

这是我的最后一层:

...
hid = Conv2D(128, kernel_size=5, strides=1, padding='same')(hid)
hid = BatchNormalization(momentum=0.9)(hid)
hid = LeakyReLU(alpha=0.1)(hid)

hid = Conv2D(3, kernel_size=5, strides=1, padding="same")(hid)
out = Activation("tanh")(hid)

model = Model(input_layer, out)
summary = ascii(model)

你知道该怎么办吗?

0 个答案:

没有答案