Search code examples
pythontensorflowattributeerrorlstmrecurrent-neural-network

Tensorflow rnn: name 'seq2seq' is not defined


I am trying this notebook: https://github.com/sjchoi86/Tensorflow-101/blob/master/notebooks/char_rnn_sample_tutorial.ipynb

I have a problem with this line In[6]:

outputs, final_state = seq2seq.rnn_decoder(inputs, istate, cell, loop_function=None, scope='rnnlm')

I get this error:

NameError: name 'seq2seq' is not defined

I am using tensorflow 1.0.1. I tried

tf.contrib.seq2seq

but I am getting error:

AttributeError: 'module' object has no attribute 'rnn_decoder'

I think it is a probleme with the new implementation of rnn network in tensorflow 1.0.1 but I don't know how to fix it.


Solution

  • Because seq2seq has been moved to tf.contrib.legacy_seq2seq. You should change this line to:

    outputs, final_state = tf.contrib.legacy_seq2seq.rnn_decoder(inputs, istate, cell, loop_function=None, scope='rnnlm')