当前位置:网站首页>Tensorflow1. X and 2 How does x read those parameters saved in CKPT
Tensorflow1. X and 2 How does x read those parameters saved in CKPT
2022-04-23 20:48:00 【NuerNuer】
about 1.x Of tf edition , There have been many introductions on the Internet , Here's the code :
import tensorflow as tf
import os
from tensorflow.python import pywrap_tensorflow
model_dir='./model'# Set the folder where the model is located
checkpoint_path = os.path.join(model_dir, "fineturing_model.ckpt")# location ckpt file
# from checkpoint Read out the data in the computer
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
# reader = tf.train.NewCheckpointReader(checkpoint_path) # use tf.train Medium NewCheckpointReader Method
var_to_shape_map = reader.get_variable_to_shape_map()
# Output weight tensor Name and value
for key in var_to_shape_map:
print("tensor_name: ", key,reader.get_tensor(key).shape)
about tensorflow2.0 Come on , This code doesn't work properly , It's like :
module 'tensorflow.python.pywrap_tensorflow' has no attribute 'NewCheckpointReader'
Error of , This is the problem with the version , Some bloggers suggest reducing tf edition , But it's a little too expensive , Here's how tf2.0 The correct way to use ;
import tensorflow.compat.v1 as tf1
tf1.disable_v2_behavior()
checkpoint_path = 'xxx.ckpt'
# Read data from checkpoint file
reader = tf1.train.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).shape)
版权声明
本文为[NuerNuer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210545522534.html
边栏推荐
- Elastic box model
- Recommended usage scenarios and production tools for common 60 types of charts
- GO语言开发天天生鲜项目第三天 案例-新闻发布系统二
- 41. The first missing positive number
- 亚马逊和Epic将入驻,微软应用商城向第三方开放
- [SQL] string series 2: split a string into multiple lines according to specific characters
- Use of node template engine
- go interface
- Gsi-ecm digital platform for engineering construction management
- Summary and effect analysis of methods for calculating binocular parallax
猜你喜欢

【SQL】字符串系列2:将一个字符串根据特定字符分拆成多行

Express③(使用Express编写接口、跨域有关问题)

Matlab matrix index problem

中创存储|想要一个好用的分布式存储云盘,到底该怎么选

Another data analysis artifact: Polaris is really powerful

Fastdfs思维导图

Matlab: psychtoolbox installation

Identifier CV is not defined in opencv4_ CAP_ PROP_ FPS; CV_ CAP_ PROP_ FRAME_ COUNT; CV_ CAP_ PROP_ POS_ Frames problem

2021-09-02 unity project uses rider to build hot change project failure record of ilruntime

Linux中,MySQL的常用命令
随机推荐
Rust更适合经验较少的程序员?
Leetcode 74. Search two-dimensional matrix
Resolve the error - error identifier 'attr_ id‘ is not in camel case camelcase
Leetcode 709, convert to lowercase
wait、waitpid
Flex layout
mmap、munmap
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
Some thoughts on super in pytorch, combined with code
go interface
Singleton mode
Bracket matching -- [implementation of one-dimensional array]
小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌
Create vs project with MATLAB
Graph traversal - BFS, DFS
Sequential state
缓存淘汰算法初步认识(LRU和LFU)
Recommended usage scenarios and production tools for common 60 types of charts
MySQL数据库常识之储存引擎
Solve the Chinese garbled code of URL in JS - decoding