1、首先需要安装graph
1. (使用pip install)安装pydot和graphviz两个函数库
2. 安装graphviz软件:
3. 将路径加入系统变量,从我的电脑-属性-高级系统设置-环境变量 进入(win10配置完后需要重启生效)
4、生成对应的模型结构:
import configparser
import tensorflow as tf
from utils.path_utils import get_full_path
config = configparser.ConfigParser()
config.read(get_full_path('conf/config.txt'), encoding="utf-8")
algorithm_version = config.get('version', 'version')
my_model = tf.keras.models.load_model(get_full_path(config.get('lstm_model', 'model_path')))
tf.keras.utils.plot_model(my_model, to_file=get_full_path('data/train_data/model_structure.png'), show_shapes=False,
show_layer_names=True, rankdir="LR", expand_nested=True)