Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 25a16a29 authored by Neal Wu's avatar Neal Wu
Browse files

Don't reuse the same cell when creating MultiRNNCell in ptb_word_lm.py

parent a7f1c5ed
No related branches found
No related tags found
No related merge requests found
......@@ -213,13 +213,15 @@ class PTBModel(object):
# Slightly better results can be obtained with forget gate biases
# initialized to 1 but the hyperparameters of the model would need to be
# different than reported in the paper.
cell = self._get_lstm_cell(config, is_training)
if is_training and config.keep_prob < 1:
cell = tf.contrib.rnn.DropoutWrapper(
cell, output_keep_prob=config.keep_prob)
def make_cell():
cell = self._get_lstm_cell(config, is_training)
if is_training and config.keep_prob < 1:
cell = tf.contrib.rnn.DropoutWrapper(
cell, output_keep_prob=config.keep_prob)
return cell
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())
state = self._initial_state
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment