我在 TensorFlow 1.0 中有以下代码。我尝试使用 tf_upgrade_v2 脚本将其迁移到 TensorFlow 2.0。然而,在tf-2紧凑版本中没有找到等效的功能。
建议我使用tensorflow_addons。但是,我在 tf_addons 模块中没有看到等效的注意力解码器。请指导我。
decoder_outputs,decoder_state = tf.contrib.legacy_seq2seq.attention_decoder(
decoder_inputs = decoder_inputs,
initial_state = encoder_state,
attention_states = encoder_outputs,
cell = cell,
output_size = word_embedding_dim,
loop_function = None if mode=='pretrain' else feed_prev_loop,
scope = scope
)
Run Code Online (Sandbox Code Playgroud)
tf 1.0代码的链接在这里: https://github.com/yaushian/CycleGAN-sentiment-transfer/blob/master/lib/seq2seq.py