问题描述
限时送ChatGPT账号..我想查看保存在 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屋!
更多推荐
[db:关键词]
发布评论