背景
有时候我们需要探查模型参数,或者在调用模型提示参数错误时,也需要查看模型参数来定位问题,以下是针对不同存储格式的模型,对参数做读取操作
checkpoint模型
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import tensorflow as tf
from tensorflow.python import pywrap_tensorflow
def show_ckp_params():
model_dir = "./output/choose_model"
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