与此相关的复制变量:How can I copy a variable in tensorflowtensorflow在RNN
我试图复制LSTM解码单元的值在其他地方使用它beamsearch。在伪代码,我想是这样的:
lstm_decode = tf.nn.rnn_cell(...)
training_output = tf.nn.seq2seq.rnn_decoder(...)
... do training by back-prop the error on trainint_output ...
# duplicate the lstm_decode unit (same weights)
lstm_decode_copy = copy(lstm_decode)
... do beam search with the duplicated lstm ...
的问题是,在tensorflow,没有召唤“tf.nn.rnn_cell(......)”过程中产生的LSTM变量,但它是实际上是在函数调用展开到rnn_decoder期间生成的。
我可以将范围设置为“tf.nn.seq2seq.rnn_decoder”函数调用,但lstm权重的实际初始化对我来说并不透明。我如何捕获这些值并重新使用它们来创建一个与所学的权重相同的lstm单元?
谢谢!