Keras:找出层数
Keras: find out the number of layers
有没有办法获取 Keras 模型中的层数(不是参数)?
model.summary()
信息量很大,但是从中获取层数并不简单。
model.layers
将为您提供所有图层的列表。因此这个数字是 len(model.layers)
要获取图层的图形视图,您可以使用:
from keras.utils.vis_utils import plot_model
plot_model(model, to_file='layers_plot.png', show_shapes=True, show_layer_names=True)
你需要pip install pydot
从 https://graphviz.gitlab.io/download/
下载并安装 graphviz
附上一个
sample output image
有没有办法获取 Keras 模型中的层数(不是参数)?
model.summary()
信息量很大,但是从中获取层数并不简单。
model.layers
将为您提供所有图层的列表。因此这个数字是 len(model.layers)
要获取图层的图形视图,您可以使用:
from keras.utils.vis_utils import plot_model
plot_model(model, to_file='layers_plot.png', show_shapes=True, show_layer_names=True)
你需要pip install pydot
从 https://graphviz.gitlab.io/download/
下载并安装 graphviz
附上一个
sample output image