且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何找到保存在检查点中的变量名称和值?

更新时间:2023-12-02 12:15:16

您可以使用 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='')