Commit 167b6c69 authored by Neal Wu's avatar Neal Wu
Browse files

Make ptb_word_lm compatible with the latest TensorFlow source while...

Make ptb_word_lm compatible with the latest TensorFlow source while maintaining backwards compatibility with TF 1.0
parent 7b4d025a
......@@ -109,6 +109,15 @@ class PTBModel(object):
# initialized to 1 but the hyperparameters of the model would need to be
# different than reported in the paper.
def lstm_cell():
# With the latest TensorFlow source code (as of Mar 27, 2017),
# the BasicLSTMCell will need a reuse parameter which is unfortunately not
# defined in TensorFlow 1.0. To maintain backwards compatibility, we add a
# try-except here:
try:
return tf.contrib.rnn.BasicLSTMCell(
size, forget_bias=0.0, state_is_tuple=True,
reuse=tf.get_variable_scope().reuse)
except TypeError:
return tf.contrib.rnn.BasicLSTMCell(
size, forget_bias=0.0, state_is_tuple=True)
attn_cell = lstm_cell
......
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