如何查看ckpt tensor name 和 meta转换成summary

1. 从ckpt查看tensor name

tf.Saver得到 model.ckpt.index和model.ckpt.data-**文件,其中保存了所有变量的取值。其中model.ckpt.data文件通过SSTable格式存储的,可以大致理解为一个(key, value)列表。TensorFlow提供了tf.train.NewCheckpointReader类来查看保存的变量信息。

import tensorflow as tf

reader = tf.train.NewCheckpointReader('Saved_model/model.ckpt')

global_variables = reader.get_variable_to_shape_map()
for variable_name in global_variables:
    print(variable_name)
    print(global_variables[variable_name])
    
print("Value for variable v1 is")
print(reader.get_tensor("v1"))

 

2. 导出meta到summary,用tensorboard查看

import tensorflow as tf
from tensorflow.python.platform import gfile

graph = tf.get_default_graph()
graphdef = graph.as_graph_def()
_ = tf.train.import_meta_graph('meta的路径/xxxx.meta')
summary = tf.summary.FileWriter('summary的路径', graph)

 

3. 导出到meta graph json格式

TensorFlow提供了export_meta_graph函数,这个函数支持以json格式导出MetaGraphDefProtocolBuffer。

import tensorflow as tf

saver = tf.train.import_meta_graph("Saved_model/model.ckpt.meta")

saver.export_meta_graph("Saved_model/model.ckpt.meta.json")

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值