当我尝试使用tensorflow 2.1导入tensorflow_addons
时遇到以下错误
> import tensorflow_addons as tfa
AttributeError: module 'tensorflow_core._api.v2.random' has no attribute 'Generator'
答案 0 :(得分:8)
您的Tensorflow和Tensorflow-addons版本之间存在不兼容性。 要解决您的问题,请卸载当前版本,然后将其替换为正确的版本,只需选中此table
一些提醒: 要在终端中检查您的Tensorflow版本:
python -c 'import tensorflow as tf; print(tf.__version__)'
答案 1 :(得分:2)
我能够通过修补tf.random.Generator
import tensorflow as tf
tf.random.Generator = None # Patch for a bug
import tensorflow_addons as tfa
答案 2 :(得分:2)
检查您的张量流版本-
import tensorflow as tf
print(tf.__version__)
检查相应的tf-addons版本here
卸载以前的版本并安装正确的版本-
pip uninstall tensorflow-addons
pip install tensorflow-addons==[version-number]
例如-pip install tensorflow-addons==0.9.1
用于tensorflow版本2.1.0