model.ckpt训练数据保存与读取

保存:

saver = tf.train.Saver()
saver.save(sess, './model/model.ckpt', global_step=i)

读取:

model_dir = "./model/"				# 文件路径
reader = tf.train.NewCheckpointReader(tf.train.get_checkpoint_state(model_dir).model_checkpoint_path)
data_dict = reader.get_variable_to_shape_map()
for key in data_dict:
	# Print tensor name and values
	print("tensor_name: ", key)
	print(reader.get_tensor(key))
	# save
	f = open('./model/tensor.txt', 'a')
	f.write(key)
	f.write(str(reader.get_tensor(key)))
	f.write('\r\n')
	f.close()

你可能感兴趣的:(深度学习)