Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to copy variblaes in LSTM #355

Open
tachiang opened this issue Mar 3, 2020 · 0 comments
Open

How to copy variblaes in LSTM #355

tachiang opened this issue Mar 3, 2020 · 0 comments

Comments

@tachiang
Copy link

tachiang commented Mar 3, 2020

There are two attention based seq2seq network implemented by tf.contrib.rnn (tensorflow 1.11) and they are of the same network architecture. One is evalation network and the other one is target network. The evalation network is updaed at each iteration and the target network copy weights (variables) from the evaluation network at every 1000 iterations. Since the varibales in LSTM seems to be not available to deginers, how to copy variables of the evaluation network to the target network?

########################################################
Key codes in evaluation network
########################################################
with tf.variable_scope('eval_net'):
tf.contrib.rnn.LSTMCell(self.rnn_size)
...
encoder_outputs, encoder_state = tf.nn.dynamic_rnn(enc_cell, encoder_inputs, enc_input_lens, dtype=tf.float32)
...
my_decoder = tf.contrib.seq2seq.BasicDecoder(dec_cell,
my_helper,
decoder_initial_state,
output_layer=output_layer # applied per timestep
)
actor_outputs, _, _ = tf.contrib.seq2seq.dynamic_decode(my_decoder, maximum_iterations=self.max_input_seq_len)
...
########################################################
Key codes in target network
########################################################
with tf.variable_scope('target_net'):
tf.contrib.rnn.LSTMCell(self.rnn_size)
...
encoder_outputs, encoder_state = tf.nn.dynamic_rnn(enc_cell, encoder_inputs, enc_input_lens, dtype=tf.float32)
...
my_decoder = tf.contrib.seq2seq.BasicDecoder(dec_cell,
my_helper,
decoder_initial_state,
output_layer=output_layer # applied per timestep
)
actor_outputs, _, _ = tf.contrib.seq2seq.dynamic_decode(my_decoder, maximum_iterations=self.max_input_seq_len)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant