Reputation: 154
I have followed every step from here https://edouardfouche.com/Fun-with-Tensorflow-im2txt/ but i get the following error
NotFoundError (see above for traceback): Tensor name "lstm/basic_lstm_cell/bias" not found in checkpoint files /home/asadmahmood72/Image_to_text/models/im2txt/model.ckpt-3000000 [[Node: save/RestoreV2_380 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_380/tensor_names, save/RestoreV2_380/shape_and_slices)]]
My os is UBUNTU 16.04 my tensorflow version is 1.2.0
Upvotes: 0
Views: 575
Reputation: 696
This is a bit late, but hopefully this answer will help future people who encounter this problem.
Like Edouard mentioned, this error is caused because of a change in the Tensorflow API. If you want to use a more recent version of Tensorflow, there are a few ways I know of to "update" your checkpoint:
checkpoint_convert.py
utility included in Tensorflow, orUse this solution written by 0xDFDFDF on GitHub to rename the offending variables:
OLD_CHECKPOINT_FILE = "model.ckpt-1000000"
NEW_CHECKPOINT_FILE = "model2.ckpt-1000000"
import tensorflow as tf
vars_to_rename = {
"lstm/basic_lstm_cell/weights": "lstm/basic_lstm_cell/kernel",
"lstm/basic_lstm_cell/biases": "lstm/basic_lstm_cell/bias",
}
new_checkpoint_vars = {}
reader = tf.train.NewCheckpointReader(OLD_CHECKPOINT_FILE)
for old_name in reader.get_variable_to_shape_map():
if old_name in vars_to_rename:
new_name = vars_to_rename[old_name]
else:
new_name = old_name
new_checkpoint_vars[new_name] = tf.Variable(reader.get_tensor(old_name))
init = tf.global_variables_initializer()
saver = tf.train.Saver(new_checkpoint_vars)
with tf.Session() as sess:
sess.run(init)
saver.save(sess, NEW_CHECKPOINT_FILE)
I used option #2, and loading my checkpoint worked perfectly after that.
Upvotes: 1
Reputation: 11
it looks like the tensorflow API changed again, which makes it incompatible with the checkpoint model. I was using tensorflow 0.12.1 in the article. Can you try with tensorflow 0.12.1 if it works? Otherwise you will have to train the model yourself (expensive) or find a checkpoint file that was generated with a more recent version of tensorflow...
Upvotes: 1