plot_model
函数keras.utils.plot_model(
model,
to_file="model.png",
show_shapes=False,
show_dtype=False,
show_layer_names=False,
rankdir="TB",
expand_nested=False,
dpi=200,
show_layer_activations=False,
show_trainable=False,
**kwargs
)
将 Keras 模型转换为 dot 格式并保存到文件。
示例
inputs = ...
outputs = ...
model = keras.Model(inputs=inputs, outputs=outputs)
dot_img_file = '/tmp/model_1.png'
keras.utils.plot_model(model, to_file=dot_img_file, show_shapes=True)
参数
rankdir
参数,一个字符串,指定绘制格式:"TB"
创建垂直图;"LR"
创建水平图。activation
属性的层)。返回值
如果安装了 Jupyter,则返回一个 Jupyter notebook Image 对象。这使得在 notebook 中可以内联显示模型图。
model_to_dot
函数keras.utils.model_to_dot(
model,
show_shapes=False,
show_dtype=False,
show_layer_names=True,
rankdir="TB",
expand_nested=False,
dpi=200,
subgraph=False,
show_layer_activations=False,
show_trainable=False,
**kwargs
)
将 Keras 模型转换为 dot 格式。
参数
rankdir
参数,一个字符串,指定绘制格式:"TB"
创建垂直图;"LR"
创建水平图。pydot.Cluster
实例。activation
属性的层)。返回值
一个表示 Keras 模型的 pydot.Dot
实例,如果 subgraph=True
,则返回一个表示嵌套模型的 pydot.Cluster
实例。