Tensorflow 1.0以上版本中,如何读取模型文件及其权重数值?

2026-06-09 17:171阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计214个文字,预计阅读时间需要1分钟。

Tensorflow 1.0以上版本中,如何读取模型文件及其权重数值?

保存的文件有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():

保存的文件有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')

以上这篇Tensorflow 1.0之后模型文件、权重数值的读取方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

Tensorflow 1.0以上版本中,如何读取模型文件及其权重数值?

本文共计214个文字,预计阅读时间需要1分钟。

Tensorflow 1.0以上版本中,如何读取模型文件及其权重数值?

保存的文件有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():

保存的文件有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')

以上这篇Tensorflow 1.0之后模型文件、权重数值的读取方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

Tensorflow 1.0以上版本中,如何读取模型文件及其权重数值?