0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

assign requires shapes of both tensors to matchの解決法

Last updated at Posted at 2021-04-09

概要

以下のようなエラーが出た際の対処法

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:
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?