概要
以下のようなエラーが出た際の対処法
restoring from checkpoint failed. this is most likely due to a mismatch between
the current graph and the graph from the checkpoint. please ensure that you have
not altered the graph expected based on the checkpoint
内容
以下のようにtensoflow1系でのsavedmodelを二つ読み込む際に一度runしたモデルでもう一方もrunしてしまう
with tf.Session() as sess:
model = tf.saved_model.loader.load(sess, [tag_constants.SERVING], export_path1)
sig = model_x.signature_def[signature_name]
inp = sig_def.inputs[input].name
out = sig_def.outputs[output].name
output = sess.run(out,
feed_dict={inp: my_data})
with tf.Session() as sess:
model = tf.saved_model.loader.load(sess, [tag_constants.SERVING], export_path2)
sig = model_x.signature_def[signature_name]
inp = sig_def.inputs[input].name
out = sig_def.outputs[output].name
output = sess.run(out,
feed_dict={inp: my_data})
解決法
Session()内にgraph=tf.Graph()を記載する
with tf.Session(graph=tf.Graph()) as sess: