2016-11-01 8 views
1

私は順序で何かをするtensorflowでプログラムを作成しようとしています。 tf.nn.seq2seq関数のオプションは、feed_previousパラメーターです。これは私が列車時に使用できるものですが、評価/ランタイムでは使用できません。 Tensorflow再利用rnn_seq2seqモデル

(outputs_dict,state_dict) = tf.nn.seq2seq.one2many_rnn_seq2seq(enc_inp,decoder_inputs_dictionary,cell, vocab_size, decoder_symbols_dictionary,embedding_size=embedding_dim) 
(evaluation_dict,evaluation_state_dict) = tf.nn.seq2seq.one2many_rnn_seq2seq(enc_inp,decoder_inputs_dictionary,cell, vocab_size, decoder_symbols_dictionary,embedding_size=embedding_dim,feed_previous=True) 

しかし、私はエラーを取得する:現在、私はこれを試してみました「とValueError:変数one2many_rnn_seq2seq/RNN/EmbeddingWrapper /埋め込みがすでに存在しているが、許可されていないあなたはVarScopeで真の再利用を=に設定することを意味しましたか?」

誰も私がトレーニング中ではなく、評価中にfeed_previous使用できるように、私のモデルを再利用する方法に

  • 知っていますか?
+0

あなたは(https://www.tensorflow.org/versions/r0.11/how_tos/ [variable_scope]を考えがありますvariable_scope/index.html)?同じ名前の変数スコープで両方を折り返し、2番目のスコープに対してreuse = Trueを設定します。 –

+0

Welp、それだけです! この場合、可変スコープを使用する方法が明確ではありませんでしたが、修正に使用したコードの回答を見てください。 – rmeertens

答えて

1

アレンは正しい方向に私を指摘しました!

私は私の問題を解決するために使用されるコードは(と思う)です:

with tf.variable_scope("decoder1") as scope: 
    (outputs_dict, state_dict) = tf.nn.seq2seq.one2many_rnn_seq2seq(enc_inp, train_decoder_inputs_dictionary, 
                    cell, vocab_size, decoder_symbols_dictionary, 
                    embedding_size=embedding_dim, feed_previous=True) 
with tf.variable_scope("decoder1",reuse=True) as scope: 
    (runtime_outputs_dict, runtime_state_dict) = tf.nn.seq2seq.one2many_rnn_seq2seq(enc_inp, runtime_decoder_inputs_dictionary, 
                    cell, vocab_size, decoder_symbols_dictionary, 
                    embedding_size=embedding_dim, feed_previous=True) 
関連する問題