Tensorflow rnn:未定义名称“seq2seq”

时间:2017-04-10 17:51:31

标签: python tensorflow attributeerror lstm recurrent-neural-network

我正在尝试这款笔记本: https://github.com/sjchoi86/Tensorflow-101/blob/master/notebooks/char_rnn_sample_tutorial.ipynb

我对[6]中的这一行有疑问:

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

我收到此错误:

NameError: name 'seq2seq' is not defined

我正在使用tensorflow 1.0.1。我试过了

tf.contrib.seq2seq

但我收到错误:

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

我认为在tensorflow 1.0.1中对rnn网络的新实现存在问题,但我不知道如何修复它。

1 个答案:

答案 0 :(得分:5)

因为seq2seq已移至tf.contrib.legacy_seq2seq。您应该将此行更改为:

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