tensorflow直接读取ckpt中的变量

ref:https://blog.csdn.net/u014365862/article/details/79397919

import tensorflow as tf
  
reader = tf.train.NewCheckpointReader("./model.ckpt")  
  
variables = reader.get_variable_to_shape_map()  
  
for v in variables: 
    w = reader.get_tensor(v)  
    print(type(w))  
    # print(w.shape) 
    # print (w[0]) 
    print(w)
posted @ 2021-07-26 16:07  wioponsen  阅读(96)  评论(0编辑  收藏  举报