tensorflow - Tensorflow如何检查模型
问题描述
我建立了一个 Tensorflow RNN 模型并想检查模型结果(例如,使用了哪些特征/变量以及强度等)
我创建了以下文件:
- 检查点
- my_time_series_model
- my_time_series_model.index
- my_time_series_model 元数据
- 火车.PBTXT
但是我在阅读这些文件时遇到了问题。我找到了以下代码:
from tensorflow.python import pywrap_tensorflow
model_file = "/trained/checkpoint"
reader = pywrap_tensorflow.NewCheckpointReader(model_file)
var_to_shape_map = reader.get_variable_to_shape_map()
for key in sorted(var_to_shape_map):
print("tensor_name: ", key)
print(reader.get_tensor(key))
我收到以下错误:
检查点:数据丢失:不是 sstable(坏幻数):您的文件可能是不同的文件格式,您需要使用不同的恢复操作符?
检查点是错误的文件吗?它在我的文件夹中没有扩展名,它只是说类型是数据?
任何帮助都会很棒!
解决方案
您可以使用inspect_checkpoint
tensorflow python 工具中的功能检查检查点的张量。
来自张量流文档的示例:
# import the inspect_checkpoint library
from tensorflow.python.tools import inspect_checkpoint as chkp
# print all tensors in checkpoint file
chkp.print_tensors_in_checkpoint_file("/tmp/model.ckpt", tensor_name='', all_tensors=True)
# tensor_name: v1
# [ 1. 1. 1.]
# tensor_name: v2
# [-1. -1. -1. -1. -1.]
https://www.tensorflow.org/guide/saved_model#inspect_variables_in_a_checkpoint
推荐阅读
- ruby-on-rails - 没有路由匹配 [GET] "/oauth/applications"
- bash - 如何在使用 rsync 覆盖文件之前备份文件
- c++ - 使用CGAL存储多边形的顶点、半边、邻接列表
- delphi - Inno.TLabel 在使用 GDI+ 时未显示
- tensorflow - TensorFlow Hub 缓存模型 - 加载时权限被拒绝
- python - Discord.py 如何在重写中删除单数消息
- java - 在 Java 泛型接口中推断类参数的类型
- android - 如何以及在何处存储要在应用程序中显示的大量图像
- spring - 使用片段时 Thymeleaf PDF 模板解析错误
- reactjs - 如何从子组件中获取价值?