执行时出现 AttributeErro :rmodule 'tensorflow._api.v2.nn' has no attribute 'seq2seq' 报错

执行环境tensorflow=2.9.1 , Python 3.7.1
当我再执行这串程式码
self.outputs, self.final_state = tf.nn.seq2seq.rnn_decoder(
decoder_inputs=self.inputs,
initial_state=None, # The initial state is defined inside KeyboardCell
cell=KeyboardCell(self.args),
loop_function=loop_rnn
)
会出现AttributeErro :rmodule ‘tensorflow._api.v2.nn’ has no attribute ‘seq2seq’ 报错
这个code当时的执行环境是tensorflow 0.10.0
想请问在tensorflow2.9.1的环境该如何改写

您好,TensorFlow 0.10这个版本确实是有点旧了,现在的TensorFlow的API变化很大。如果您只是想让您的代码运行起来,建议安装旧版的TensorFlow运行。如果您确实需要改写这段代码到TensorFlow 2.X,可以参考 https://www.tensorflow.org/addons/api_docs/python/tfa/seq2seqhttps://www.tensorflow.org/addons/tutorials/networks_seq2seq_nmt