Skip to content

Instantly share code, notes, and snippets.

@oplatek
Last active May 11, 2016 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oplatek/abae0f30e2bcef0d678f07f400676d74 to your computer and use it in GitHub Desktop.
Save oplatek/abae0f30e2bcef0d678f07f400676d74 to your computer and use it in GitHub Desktop.
self.is_first_turn = tf.placeholder(tf.bool)
logger.debug('We get input features for each turn, to represent dialog, we need to store the state between the turns')
dialog_state_before_turn = tf.get_variable('dialog_state_before_turn', initializer=encoder_cell.zero_state(c.batch_size))
dialog_state_before_turn = control_flow_ops.cond(self.is_first_turn,
lambda: encoder_cell.zero_state(c.batch_size),
lambda: dialog_state_before_turn)
logger.debug('Initialization of encoder inputs and control flow took %.2f s.', inpt_timer())
words_hidden_feat, dialog_state_after_turn = tf.nn.rnn(encoder_cell, embedded_inputs,
initial_state=dialog_state_before_turn, sequence_length=turn_len)
tf.assign(dialog_state_before_turn, dialog_state_after_turn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment