Key not found in checkpoint - tensorflow model

This error appears when we are trying to load a saved model from the checkpoint directory.

The error will look similar to below,

2017-05-17 05:10:03.764397: W tensorflow/core/framework/op_kernel.cc:1169] Not found: Key conv-maxpool-7/W/Adam not found in checkpoint
2017-05-17 05:10:03.765525: W tensorflow/core/framework/op_kernel.cc:1169] Not found: Key conv-maxpool-7/b not found in checkpoint
2017-05-17 05:10:03.768765: W tensorflow/core/framework/op_kernel.cc:1169] Not found: Key conv-maxpool-7/b/Adam_1 not found in checkpoint
2017-05-17 05:10:03.769452: W tensorflow/core/framework/op_kernel.cc:1169] Not found: Key conv-maxpool-7/W/Adam_1 not found in checkpoint
2017-05-17 05:10:03.770109: W tensorflow/core/framework/op_kernel.cc:1169] Not found: Key conv-maxpool-7/W not found in checkpoint
2017-05-17 05:10:03.770577: W tensorflow/core/framework/op_kernel.cc:1169] Not found: Key conv-maxpool-7/b/Adam not found in checkpoint
Traceback (most recent call last):
File "train.py", line 192, in <module>
saver.restore(sess,save_path)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1545, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 786, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 994, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1129, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1149, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key conv-maxpool-7/W/Adam not found in checkpoint
[[Node: save/RestoreV2_18 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_18/tensor_names, save/RestoreV2_18/shape_and_slices)]]
Caused by op u'save/RestoreV2_18', defined at:
File "train.py", line 150, in <module>
saver = tf.train.Saver(tf.global_variables(), max_to_keep=FLAGS.num_checkpoints)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1139, in __init__
self.build()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1170, in build
restore_sequentially=self._restore_sequentially)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 691, in build
restore_sequentially, reshape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 407, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 247, in restore_op
[spec.tensor.dtype])[0])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_io_ops.py", line 680, in restore_v2
dtypes=dtypes, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1228, in __init__
self._traceback = _extract_stack()
NotFoundError (see above for traceback): Key conv-maxpool-7/W/Adam not found in checkpoint
[[Node: save/RestoreV2_18 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_18/tensor_names, save/RestoreV2_18/shape_and_slices)]]

This error will occur only when the model or any linked parameter has been changed in the code. In my case the hyperparameter, filter size was changed hence I was receiving this error. I restored it back to its original value and reloaded the model, it worked fine.

results for ""

    No results matching ""