Python NotFoundError:使用TensorFlow时,在检查点中找不到键变量

Python NotFoundError:使用TensorFlow时,在检查点中找不到键变量,python,tensorflow,Python,Tensorflow,我阅读了TensorFlow使用Seq2SeqModel的translate.py,并对其感兴趣,我想使用两个seq2seq模型(BotEngine,GrammarGenerator),使用TF教程代码中使用的translate.py,如下所示 with tf.Session() as sess: with tf.variable_scope("be_model"): model_be = BotEngine.create_model(sess, True)

我阅读了TensorFlow使用Seq2SeqModel的translate.py,并对其感兴趣,我想使用两个seq2seq模型(BotEngine,GrammarGenerator),使用TF教程代码中使用的translate.py,如下所示

    with tf.Session() as sess:
    with tf.variable_scope("be_model"):
        model_be = BotEngine.create_model(sess, True)
        print("be model created")
    with tf.variable_scope("gg_model"):
        model_gg = GrammarGenerator.create_model(sess, True)
        print("gg model created")
当我分别训练和测试这两个模型时(在读取检查点文件之后),没有发生错误。但是,当我连续读取两个检查点文件时,会出现以下错误:

(tensorflow) C:\test>python conversation.py --conversation 2017-10-05 14:43:52.150316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations. 2017-10-05 14:43:52.150316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-05 14:43:52.150316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-05 14:43:52.150316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use SSE4.1 instructions, but these are available on your machine a nd could speed up CPU computations. 2017-10-05 14:43:52.150316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use SSE4.2 instructions, but these are available on your machine a nd could speed up CPU computations. 2017-10-05 14:43:52.150316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-10-05 14:43:52.151316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-05 14:43:52.151316: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn' t compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. Reading model parameters from ./seq2seq_bemodel\seq2seq.ckpt-6000 [be model created] Reading model parameters from ./seq2seq_ggmodel\seq2seq.ckpt-43800 2017-10-05 14:45:06.332559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/Variable_ 1 not found in checkpoint 2017-10-05 14:45:06.333559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/be_pro_w not found in checkpoint 2017-10-05 14:45:06.334559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/Variable not found in checkpoint 2017-10-05 14:45:06.337559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/Attention_0/bia s not found in checkpoint 2017-10-05 14:45:06.338559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/be_proj_b not found in checkpoint 2017-10-05 14:45:06.341559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/Attention_0/ker nel not found in checkpoint 2017-10-05 14:45:06.344559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/AttnOutputProje ction/bias not found in checkpoint 2017-10-05 14:45:06.345559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/AttnOutputProje ction/kernel not found in checkpoint 2017-10-05 14:45:06.346559: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/AttnV_0 not fou nd in checkpoint 2017-10-05 14:45:06.348560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/AttnW_0 not fou nd in checkpoint 2017-10-05 14:45:06.351560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/bias not found in checkpoint 2017-10-05 14:45:06.353560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/kernel not foun d in checkpoint 2017-10-05 14:45:06.355560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/ cell_0/lstm_cell/bias not found in checkpoint 2017-10-05 14:45:06.359560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/ cell_0/lstm_cell/kernel not found in checkpoint 2017-10-05 14:45:06.360560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/ cell_1/lstm_cell/kernel not found in checkpoint 2017-10-05 14:45:06.362560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/ cell_1/lstm_cell/bias not found in checkpoint 2017-10-05 14:45:06.363560: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/ cell_2/lstm_cell/bias not found in checkpoint 2017-10-05 14:45:06.366561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/attention_decoder/multi_rnn_cell/ cell_2/lstm_cell/kernel not found in checkpoint 2017-10-05 14:45:06.367561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/embedding_attention_decoder/embedding not found in checkpoint 2017-10-05 14:45:06.371561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/embedding not found in checkpoint 2017-10-05 14:45:06.374561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/multi_rnn_cell/cell_0/lstm_cell/bias no t found in checkpoint 2017-10-05 14:45:06.375561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/multi_rnn_cell/cell_0/lstm_cell/kernel not found in checkpoint 2017-10-05 14:45:06.377561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/multi_rnn_cell/cell_1/lstm_cell/bias no t found in checkpoint 2017-10-05 14:45:06.378561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/multi_rnn_cell/cell_1/lstm_cell/kernel not found in checkpoint 2017-10-05 14:45:06.379561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/multi_rnn_cell/cell_2/lstm_cell/bias no t found in checkpoint 2017-10-05 14:45:06.381561: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2. 1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key be_model/embedding _attention_seq2seq/rnn/embedding_wrapper/multi_rnn_cell/cell_2/lstm_cell/kernel not found in checkpoint Traceback (most recent call last): File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\client\session.py", line 1139, in _do_call return fn(*args) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\client\session.py", line 1121, in _run_fn status, run_metadata) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\contextlib.py", line 66, in __exit__ next(self.gen) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.NotFoundError: Key be_model/Variable_1 n ot found in checkpoint [[Node: gg_model/save/RestoreV2_1 = RestoreV2[dtypes=[DT_INT32], _devic e="/job:localhost/replica:0/task:0/cpu:0"](_arg_gg_model/save/Const_0_0, gg_mode l/save/RestoreV2_1/tensor_names, gg_model/save/RestoreV2_1/shape_and_slices)]] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "conversation.py", line 113, in main() File "conversation.py", line 102, in main conversation() File "conversation.py", line 55, in conversation model_gg = GrammarGenerator.create_model(sess, True) File "C:\test\GrammarGenerator.py", line 50, in create_model model.saver.restore(session,ckpt.model_checkpoint_path) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\training\saver.py", line 1548, in restore {self.saver_def.filename_tensor_name: save_path}) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\client\session.py", line 789, in run run_metadata_ptr) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\client\session.py", line 997, in _run feed_dict_string, options, run_metadata) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\client\session.py", line 1132, in _do_run target_list, options, run_metadata) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\client\session.py", line 1152, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.NotFoundError: Key be_model/Variable_1 n ot found in checkpoint [[Node: gg_model/save/RestoreV2_1 = RestoreV2[dtypes=[DT_INT32], _devic e="/job:localhost/replica:0/task:0/cpu:0"](_arg_gg_model/save/Const_0_0, gg_mode l/save/RestoreV2_1/tensor_names, gg_model/save/RestoreV2_1/shape_and_slices)]] Caused by op 'gg_model/save/RestoreV2_1', defined at: File "conversation.py", line 113, in main() File "conversation.py", line 102, in main conversation() File "conversation.py", line 55, in conversation model_gg = GrammarGenerator.create_model(sess, True) File "C:\test\GrammarGenerator.py", line 45, in create_model dtype=tf.float32) File "C:\test\seq2seq_model.py", line 159, in __init__ self.saver = tf.train.Saver(tf.global_variables()) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\training\saver.py", line 1139, in __init__ self.build() File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\training\saver.py", line 1170, in build restore_sequentially=self._restore_sequentially) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\training\saver.py", line 691, in build restore_sequentially, reshape) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\training\saver.py", line 407, in _AddRestoreOps tensors = self.restore_op(filename_tensor, saveable, preferred_shard) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\training\saver.py", line 247, in restore_op [spec.tensor.dtype])[0]) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\ops\gen_io_ops.py", line 640, in restore_v2 dtypes=dtypes, name=name) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\framework\op_def_library.py", line 767, in apply_op op_def=op_def) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\framework\ops.py", line 2506, in create_op original_op=self._default_original_op, op_def=op_def) File "C:\Users\coco\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\pyt hon\framework\ops.py", line 1269, in __init__ self._traceback = _extract_stack() NotFoundError (see above for traceback): Key be_model/Variable_1 not found in ch eckpoint [[Node: gg_model/save/RestoreV2_1 = RestoreV2[dtypes=[DT_INT32], _devic e="/job:localhost/replica:0/task:0/cpu:0"](_arg_gg_model/save/Const_0_0, gg_mode l/save/RestoreV2_1/tensor_names, gg_model/save/RestoreV2_1/shape_and_slices)]] (tensorflow) C:\test> :( (tensorflow)C:\test>python conversation.py--conversation 2017-10-05 14:43:52.150316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用SSE指令,但这些指令可在您的计算机和 可以加速CPU计算。 2017-10-05 14:43:52.150316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用SSE2指令,但这些指令可在您的计算机和 可以加速CPU计算。 2017-10-05 14:43:52.150316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用SSE3指令,但这些指令可在您的计算机和 可以加速CPU计算。 2017-10-05 14:43:52.150316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用SSE4.1指令,但这些指令可在您的计算机上获得 nd可以加速CPU计算。 2017-10-05 14:43:52.150316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用SSE4.2指令,但这些指令可在您的计算机上获得 nd可以加速CPU计算。 2017-10-05 14:43:52.150316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用AVX指令,但这些指令在您的计算机和 可以加速CPU计算。 2017-10-05 14:43:52.151316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用AVX2指令,但这些指令可在您的计算机和 可以加速CPU计算。 2017-10-05 14:43:52.151316:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\platform\cpu\u feature\u guard.cc:45]tensorflow库不可用 t编译为使用FMA指令,但这些指令可在您的机器和 可以加速CPU计算。 从./seq2seq\u bemodel\seq2seq.ckpt-6000读取模型参数 [创建模型] 从./seq2seq_ggmodel\seq2seq.ckpt-43800读取模型参数 2017-10-05 14:45:06.332559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/Variable_ 在检查点中找不到1 2017-10-05 14:45:06.333559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/be_pro_w 在检查点中找不到 2017-10-05 14:45:06.334559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/Variable 在检查点中找不到 2017-10-05 14:45:06.337559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq2seq/嵌入\u注意\u解码器/注意\u解码器/注意\u 0/bia 在检查点中找不到 2017-10-05 14:45:06.338559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/be_proj_b 在检查点中找不到 2017-10-05 14:45:06.341559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq2seq/嵌入\u注意\u解码器/注意\u解码器/注意\u 0/ker 在检查点中找不到nel 2017-10-05 14:45:06.344559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq2seq/嵌入\u注意\u解码器/注意\u解码器/AttnOutputProje 在检查点中未找到错误/偏差 2017-10-05 14:45:06.345559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq2seq/嵌入\u注意\u解码器/注意\u解码器/AttnOutputProje 在检查点中找不到Action/内核 2017-10-05 14:45:06.346559:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq 2均衡/嵌入\u注意\u解码器/注意\u解码器/AttnV\u 0非fou 检查点内的nd 2017-10-05 14:45:06.348560:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq 2均衡/嵌入\u注意\u解码器/注意\u解码器/AttnW\u 0非fou 检查点内的nd 2017-10-05 14:45:06.351560:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_model/embedding _注意\u seq2seq/嵌入\u注意\u解码器/注意\u解码器/未找到偏差 关卡 2017-10-05 14:45:06.353560:W c:\l\tensorflow_1501907206084\work\tensorflow-1.2。 1\tensorflow\core\framework\op_kernel.cc:1158]未找到:Key be_mod (tensorflow) C:\test\seq2seq_bemodel>python inspect_checkpoint.py --file_name se q2seq.ckpt-5800 be_model/Variable (DT_FLOAT) [] be_model/Variable_1 (DT_INT32) [] be_model/be_model/be_pro_w/Adam (DT_FLOAT) [2179,150]