Tensorflow使用訓練好的模型——沒有找到.ckpt文件怎麼辦

最近博主需要使用已經訓練好的模型,網上搜的教程幾乎全需要用到model.ckpt文件,我看了看我的checkpoint文件夾:
在這裏插入圖片描述
如圖,根本沒有.ckpt文件,除了一個checkpoint文件只有.meta.index.data...三種文件。

對於這種情況,讀取、使用模型可以使用以下代碼:

import tensorflow as tf

detection_graph = tf.Graph()
with tf.Session(graph=detection_graph) as sess:
    # 讀取模型
    loader = tf.train.import_meta_graph('checkpoint/model-1700000.meta')
    loader.restore(sess, tf.train.latest_checkpoint('checkpoint/'))
	
	# 一些中間過程,比如生成、處理input_data等
	...
	
	# 使用模型
	input_tensor = detection_graph.get_tensor_by_name('input_name:0')
    output_tensor = detection_graph.get_tensor_by_name('output_name:0')
    
    generated_image = sess.run([geurated_image_tensor], feed_dict={input_tensor:input_data})
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章