如何找到保存在检查点中的变量名称和值? [英] How do I find the variable names and values that are saved in a checkpoint?

查看:28
本文介绍了如何找到保存在检查点中的变量名称和值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查看保存在 TensorFlow 检查点中的变量及其值.如何找到保存在 TensorFlow 检查点中的变量名称?

I want to see the variables that are saved in a TensorFlow checkpoint along with their values. How can I find the variable names that are saved in a TensorFlow checkpoint?

我使用了 tf.train.NewCheckpointReader 解释了 此处.但是,它没有在 TensorFlow 的文档中给出.还有其他办法吗?

I used tf.train.NewCheckpointReader which is explained here. But, it is not given in the documentation of TensorFlow. Is there any other way?

推荐答案

您可以使用 inspect_checkpoint.py 工具.

You can use the inspect_checkpoint.py tool.

因此,例如,如果您将检查点存储在当前目录中,那么您可以按如下方式打印变量及其值

So, for example, if you stored the checkpoint in the current directory, then you can print the variables and their values as follows

import tensorflow as tf
from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file


latest_ckp = tf.train.latest_checkpoint('./')
print_tensors_in_checkpoint_file(latest_ckp, all_tensors=True, tensor_name='')

这篇关于如何找到保存在检查点中的变量名称和值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆