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

编程入门 行业动态 更新时间:2024-10-25 06:22:42
本文介绍了如何找到保存在检查点中的变量名称和值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-05-01 05:14:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405189.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:检查点   变量   名称

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!