首页 > 解决方案 > TensorFlow 2.2 中如何替换 tf.contrib.seq2seq.TrainingHelper

问题描述

我正在尝试从GitHub运行该项目,但我在使用 TrainingHelper 时遇到了问题。现在,我被它困住了,我不知道如何将它转换为 tf2。控制台总是返回这样的错误:

AttributeError: module 'tensorflow_addons.seq2seq' has no attribute 'TrainingHelper'

请帮我!

标签: tensorflowtensorflow2.0

解决方案


似乎是https://www.tensorflow.org/addons/api_docs/python/tfa/seq2seq/TrainingSampler

不过,api 有点不同。在 TrainingHelper 的构造函数中传递的一些参数是在 TrainingSampler.initialize() 中传递的。一些返回值也有最小的差异。所以,你必须为代码迁移做一些适配。


推荐阅读