2017-02-22 8 views
1

私は、Tensorflow r0.12で訓練されたモデルを持っており、チェックポイントファイルはSaverV2を使用して作成しました。私のモデルはrnn_cellrnn_cell.GRUCellからtensorflow.python.opsを使ったRNNでした。 1.0に変更しているので、このパッケージには、私は新しいリビジョンに私のファイルを更新するhereからtf_update.pyファイルを実行したthis answerTensorflowチェックポイントファイルを1.0に更新

に応じtensorflow.contrib.rnn.python.opscore_rnn_cell_implに移動しました。しかし、更新以来、私の古いチェックポイントファイルは機能しません。新しい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を使用していますが、CUDAでCPUのみのテンソルフローまたはテンソルフローを使用している場合にも同じエラーが発生します。これを実行する簡単な方法はありません

答えて

4

...一つのアプローチは、(get_variable_to_shape_map使用することです)

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

保存されたチェックポイントでの形状にあなたの変数名のリストを与えること。そして... instantitateセーバー、新しい名前にすなわち

old_to_new={} 
old_to_new[old_name] = new_name 

を古い名前からマップする辞書を作成し、ちょうどこれらのVARS

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

幸運を復元し、このことができます願っています。

+0

わかりやすい答えをありがとう。私は単純化のためにモデルを再トレーニングするつもりだと思っていますが、実際にはそれを行う方法があるのでうれしいです。 – jbird

関連する問題