欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

Tensorflow 1.0之后模型文件、权重数值的读取方式

时间:2021-06-27 08:23:17|栏目:Python代码|点击:

保存的文件有4个:

checkpoint

model-parameters.bin-46000.data-00000-of-00001

model-parameters.bin-46000.index

model-parameters.bin-46000.meta

读取代码:

from tensorflow.python import pywrap_tensorflow

with tf.Graph().as_default(): 
 with tf.Session() as sess:
 ckpt = tf.train.get_checkpoint_state('./checkpoint')
 if ckpt and ckpt.model_checkpoint_path:
  reader = pywrap_tensorflow.NewCheckpointReader('./checkpoint/model-parameters.bin-46000')
  all_variables = reader.get_variable_to_shape_map()
  w1 = reader.get_tensor("conv1/weight")
  print(w1.shape)
  print(w1)
  print(all_variables)
 else:
  print('No checkpoint file found')

上一篇:Python中sorted()排序与字母大小写的问题

栏    目:Python代码

下一篇:解决tensorflow添加ptb库的问题

本文标题:Tensorflow 1.0之后模型文件、权重数值的读取方式

本文地址:http://www.codeinn.net/misctech/149015.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有