from tensorflow.contrib.seq2seq import BeamSearchDecoder as beam_search_decoder
为
ModuleNotFoundError: No module named 'tensorflow.contrib'
最新版本的Tensorflow不包含contrib
,该函数如何使用?
BeamSearchDecoder现在是Tensorflow Addons的一部分,应该通过pip
单独安装:
pip install tensorflow-addons
之后,你可以像下面这样使用:
from tensorflow_addons.seq2seq import BeamSearchDecoder as beam_search_decoder
或直接按照文档和教程中的建议:
import tensorflow_addons as tfa
tfa.seq2seq.BeamSearchDecoder(...)