我需要把预先训练好的神经网络模型转换成张量流模型。代码已经使用Tensorflow进行了训练,并简单地保存为pb文件。我想这是用冰冻图做的。我的问题是,为了能够转换,我需要模型的输入和输出参数,或者转换器试图在.pb文件中找到它们,而该文件的元图中不包含“serve”标记
import os
import tensorflow as tf
facenet_model_checkpoint = "location/of/inception_v2"
model_exp = os.path.expanduser(facenet_model_checkpoint)
# Extracts the meta and ckpt file
meta_file, ckpt_file = facenet.get_model_filenames(model_exp)
with tf.Session(graph=tf.Graph()) as sess:
saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=None)
saver.restore(tf.get_default_session(), os.path.join(model_exp, ckpt_file))
converter = tf.lite.TFLiteConverter.from_saved_model(facenet_model_checkpoint)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
目前没有回答
相关问题 更多 >
编程相关推荐