tensorflow的模型文件ckpt参数获取

已知模型文件的ckpt文件,通过pywrap_tensorflow获取模型的各参数名

import tensoflow as tf
from tensorflow.python import pywrap_tensorflow

model_dir = "./ckpt/"

ckpt = tf.train.get_checkpoint_state(model_dir)
ckpt_path = ckpt.model_checkpoint_path

reader = pywrap_tensorflow.NewCheckpointReader(ckpt_path)
param_dict = reader.get_variable_to_shape_map()

for key, val in param_dict.items():
    try:
        print key, val
    except:
        pass

 

你可能感兴趣的:(tensorflow)