model_dir ="./model/"
checkpoint_path = os.path.join(model_dir, "model.ckpt-1999")
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path) # tf.train.NewCheckpointReader
var_to_shape_map = reader.get_variable_to_shape_map()
print(var_to_shape_map)
d={}
for key in var_to_shape_map:
#print("tensor_name: ", key)
c=reader.get_tensor(key)
#print(reader.get_tensor(key))
d.update({key:c})
读取ckpt中变量和值并赋值到新的字典中
最新推荐文章于 2019-12-03 17:12:44 发布