属性错误:模块';tensorflow.contrib.seq2seq和#x27;没有属性';准备"注意"&"x27;

属性错误:模块';tensorflow.contrib.seq2seq和#x27;没有属性';准备"注意"&"x27;,tensorflow,machine-learning,chatbot,Tensorflow,Machine Learning,Chatbot,我试图运行我的代码,但代码抛出了错误。 错误如下所述: AttributeError:模块“tensorflow.contrib.seq2seq”没有属性“prepare\u attention” 我将tensorflow版本更新为1.0.0.,但升级并没有解决我的问题。我也在谷歌上搜索了这个错误,但我没有得到正确的解决方案 这是代码部分,请看一下 获取培训和测试预测 training_predictions, test_predictions = seq2seq_model(tf.revers

我试图运行我的代码,但代码抛出了错误。 错误如下所述:

AttributeError:模块“tensorflow.contrib.seq2seq”没有属性“prepare\u attention”

我将tensorflow版本更新为
1.0.0.
,但升级并没有解决我的问题。我也在谷歌上搜索了这个错误,但我没有得到正确的解决方案

这是代码部分,请看一下

获取培训和测试预测

training_predictions, test_predictions = seq2seq_model(tf.reverse(inputs, [-1]),
                                                       targets,
                                                       keep_prob,
                                                       batch_size,
                                                       sequence_length,
                                                       len(answerswords2int),
                                                       len(questionswords2int),
                                                       encoding_embedding_size,
                                                       decoding_embedding_size,
                                                       rnn_size,
                                                       num_layers,
                                                       questionswords2int)






C:\Users\Maniech\Anaconda3\lib\site-packages\tensorflow_core\python\client\session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Traceback (most recent call last):

  File "<ipython-input-8-aecd893a8ef5>", line 37, in <module>
    questionswords2int)

  File "C:/Users/Maniech/Desktop/Deep NLP AZ/chatbot.py", line 292, in seq2seq_model
    batch_size)

  File "C:/Users/Maniech/Desktop/Deep NLP AZ/chatbot.py", line 258, in decoder_rnn
    batch_size)

  File "C:/Users/Maniech/Desktop/Deep NLP AZ/chatbot.py", line 201, in decode_training_set
    attention_keys, attention_values, attention_score_function, attention_construct_function = tf.contrib.seq2seq.prepare_attention(attention_states, attention_option = "bahdanau", num_units = decoder_cell.output_size)

AttributeError: module 'tensorflow.contrib.seq2seq' has no attribute 'prepare_attention'
training\u predictions,test\u predictions=seq2seq\u model(tf.reverse(输入,[-1]),
目标,,
保持警惕,
批量大小,
序列长度,
len(回答者),
len(问题2),
编码\u嵌入\u大小,
解码\u嵌入\u大小,
rnn_尺寸,
层数,
问题(第2部分)
C:\Users\Maniech\Anaconda3\lib\site packages\tensorflow\u core\python\client\session.py:1750:UserWarning:交互式会话已处于活动状态。在某些情况下,这可能会导致内存不足错误。您必须显式调用'InteractiveSession.close()`以释放其他会话持有的资源。
warnings.warn('交互式会话已处于活动状态。无法执行此操作'
回溯(最近一次呼叫最后一次):
文件“”,第37行,在
问题(第2部分)
文件“C:/Users/Maniech/Desktop/Deep NLP AZ/chatbot.py”,第292行,在seq2seq_模型中
批次(单位尺寸)
文件“C:/Users/Maniech/Desktop/Deep NLP AZ/chatbot.py”,第258行,在解码器中
批次(单位尺寸)
文件“C:/Users/Maniech/Desktop/Deep NLP AZ/chatbot.py”,第201行,在解码训练集中
注意键,注意值,注意分数函数,注意构造函数=tf.contrib.seq2seq.prepare\u注意(注意状态,注意选项=“bahdanau”,num\u units=decoder\u cell.output\u size)
AttributeError:模块“tensorflow.contrib.seq2seq”没有属性“prepare\u attention”
感谢您的帮助