更新后,Tensorflow无法从检查点加载RNN

时间:2017-09-21 21:10:38

标签: python tensorflow

将tensorflow更新到最新版本后,我的检查点无法从磁盘加载。我得到一个如下错误:

...
 File "/usr/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1560, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 895, in run
    run_metadata_ptr)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1124, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    options, run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key model/rnn/multi_rnn_cell/cell_0/lstm_cell/kernel not found in checkpoint
     [[Node: model/save/RestoreV2_4 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_model/save/Const_0_0, model/save/RestoreV2_4/tensor_names, model/save/RestoreV2_4/shape_and_slices)]]

1 个答案:

答案 0 :(得分:0)

变量名称已更改,需要在检查点中重命名。在上面的示例中,weights -> kernel

谢天谢地,有人把a script which should automatically rename your variables放在了一起。这不是第一次重命名变量并从检查点加载中断。

usage: checkpoint_convert.py [-h] [--write_v1_checkpoint]
                             checkpoint_from_path checkpoint_to_path

positional arguments:
  checkpoint_from_path  Path to source checkpoint to be read in.
  checkpoint_to_path    Path to checkpoint to be written out.

optional arguments:
  -h, --help            show this help message and exit
  --write_v1_checkpoint
                        Write v1 checkpoint