Tensorflow: 从checkpoint文件中读取tensor方式
作者:noirblack 时间:2022-07-20 11:39:29
在使用pre-train model时候,我们需要restore variables from checkpoint files.
经常出现在checkpoint 中找不到”Tensor name not found”.
这时候需要查看一下ckpt中到底有哪些变量
import os
from tensorflow.python import pywrap_tensorflow
checkpoint_path = os.path.join(model_dir, "model.ckpt")
# Read data from checkpoint file
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
var_to_shape_map = reader.get_variable_to_shape_map()
# Print tensor name and values
for key in var_to_shape_map:
print("tensor_name: ", key)
print(reader.get_tensor(key))
可以显示ckpt中的tensor名字和值,当然也可以用pycharm调试。
来源:https://blog.csdn.net/noirblack/article/details/71430790
标签:Tensorflow,checkpoint,tensor
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现排序方法常见的四种
2022-02-18 08:06:15
详解Python牛顿插值法
2023-03-05 05:58:27
![](https://img.aspxhome.com/file/2023/0/76020_0s.png)
SWFObject1.5: 基于Javascript的Flash媒体版本检测与嵌入模块
2009-08-06 18:02:00
python保存网页图片到本地的方法
2021-05-20 16:15:04
擦除式图片轮番显示效果
2013-08-10 11:01:48
基于python实现获取网页图片过程解析
2023-10-08 21:57:59
![](https://img.aspxhome.com/file/2023/2/133882_0s.png)
Python中的通函数numpy.ufunc详解
2023-09-03 22:52:08
Python 获取div标签中的文字实例
2023-03-27 01:53:53
Python中使用双下划线防止类属性被覆盖问题
2021-05-04 04:02:44
![](https://img.aspxhome.com/file/2023/2/87722_0s.jpg)
Python操作MongoDB数据库的方法示例
2022-09-03 13:48:40
Python趣味挑战之给幼儿园弟弟生成1000道算术题
2021-08-13 07:18:56
![](https://img.aspxhome.com/file/2023/0/127660_0s.png)
removeChild的障眼法
2009-12-04 12:49:00
python+pillow绘制矩阵盖尔圆简单实例
2022-07-04 02:44:39
![](https://img.aspxhome.com/file/2023/8/80428_0s.jpg)
JS基于封装函数实现的表格分页完整示例
2024-04-25 13:15:12
![](https://img.aspxhome.com/file/2023/4/135464_0s.png)
Python 数据分析之Beautiful Soup 提取页面信息
2022-04-30 04:34:10
![](https://img.aspxhome.com/file/2023/7/124247_0s.gif)
最新的关键SQL Server漏洞已被微软证实
2009-03-16 14:31:00
python使用Turtle库画画写名字
2023-12-03 03:58:38
![](https://img.aspxhome.com/file/2023/0/126920_0s.gif)
Python工程师面试题 与Python Web相关
2021-11-10 13:00:48
Navicat 连接SQLServer数据库(图文步骤)
2024-01-22 03:42:31
![](https://img.aspxhome.com/file/2023/8/113578_0s.jpg)
Python flask框架实现浏览器点击自定义跳转页面
2023-04-26 15:48:31
![](https://img.aspxhome.com/file/2023/4/89274_0s.png)