2017-02-22 58 views
1

我有一個在Tensorflow r0.12訓練的一個模式,即使用SaverV2創建檢查點文件。我的模型是從tensorflow.python.ops的RNN利用的rnn_cellrnn_cell.GRUCell。由於更改爲1.0,這個包已經根據this answer更新Tensorflow檢查文件到1.0

搬到core_rnn_cell_impltensorflow.contrib.rnn.python.ops我從heretf_update.py文件到我的檔案更新到新版本。但是,自更新以來,我的舊檢查點文件不起作用。這似乎有些由新GRUCell實施所需的變量不存在或有不同的名稱。

實施例的錯誤(有132個這樣的錯誤):

2017-02-22 11:36:08.037315: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/candidate/weights not found in checkpoint 
2017-02-22 11:36:08.037382: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/candidate/weights/Adam not found in checkpoint 
2017-02-22 11:36:08.037494: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/biases/Adam not found in checkpoint 
2017-02-22 11:36:08.037499: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/candidate/weights/Adam_1 not found in checkpoint 
2017-02-22 11:36:08.037538: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/weights not found in checkpoint 
2017-02-22 11:36:08.037615: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/biases not found in checkpoint 
2017-02-22 11:36:08.037618: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/biases/Adam_1 not found in checkpoint 
2017-02-22 11:36:08.038098: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/weights/Adam_1 not found in checkpoint 
2017-02-22 11:36:08.038121: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderAttnCell/gru_cell/gates/weights/Adam not found in checkpoint 
2017-02-22 11:36:08.038222: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderCell0/gru_cell/candidate/biases not found in checkpoint 
2017-02-22 11:36:08.038229: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderCell0/gru_cell/candidate/weights not found in checkpoint 
2017-02-22 11:36:08.038233: W tensorflow/core/framework/op_kernel.cc:993] Not found: Key NLC/Decoder/DecoderCell0/gru_cell/candidate/biases/Adam_1 not found in checkpoint 

保存/載入完美地工作,直到更新。我能做些什麼來將舊的檢查點文件更新爲r1.0?

如果它的事項,我使用python2.7和使用或者僅CPU tensorflow或tensorflow使用CUDA時,會發生同樣的錯誤。

回答

4

有沒有簡單的方法來做到這一點...一個方法是使用get_variable_to_shape_map()

ckpt_reader = tf.train.NewCheckpointReader(filepath) 
    ckpt_vars = ckpt_reader.get_variable_to_shape_map() 

,這將使你的變量名的列表中已保存的檢查點的形狀。然後......創建一個從舊名稱映射到新名稱的字典即

old_to_new={} 
old_to_new[old_name] = new_name 

然後instantitate金丹和恢復只是那些瓦爾

saver = tf.Saver(old_to_new) 
saver.restore(filepath) 

祝你好運,希望這有助於。

+0

感謝明確的答案。我想我只是爲了簡單而重新訓練模型,但我很高興有一種方法可以做到這一點。 – jbird