Unverified Commit 51228caa authored by Neal Wu's avatar Neal Wu Committed by GitHub
Browse files

Merge pull request #2868 from tensorflow/fix-ptb-multi-rnn-cell

Don't reuse the same cell when creating MultiRNNCell in ptb_word_lm.py
parents a7f1c5ed 25a16a29
...@@ -213,13 +213,15 @@ class PTBModel(object): ...@@ -213,13 +213,15 @@ class PTBModel(object):
# Slightly better results can be obtained with forget gate biases # Slightly better results can be obtained with forget gate biases
# initialized to 1 but the hyperparameters of the model would need to be # initialized to 1 but the hyperparameters of the model would need to be
# different than reported in the paper. # different than reported in the paper.
def make_cell():
cell = self._get_lstm_cell(config, is_training) cell = self._get_lstm_cell(config, is_training)
if is_training and config.keep_prob < 1: if is_training and config.keep_prob < 1:
cell = tf.contrib.rnn.DropoutWrapper( cell = tf.contrib.rnn.DropoutWrapper(
cell, output_keep_prob=config.keep_prob) cell, output_keep_prob=config.keep_prob)
return cell
cell = tf.contrib.rnn.MultiRNNCell( cell = tf.contrib.rnn.MultiRNNCell(
[cell for _ in range(config.num_layers)], state_is_tuple=True) [make_cell() for _ in range(config.num_layers)], state_is_tuple=True)
self._initial_state = cell.zero_state(config.batch_size, data_type()) self._initial_state = cell.zero_state(config.batch_size, data_type())
state = self._initial_state state = self._initial_state
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment