我得到了一个错误,当尝试导入tensorflow_model_optimization
包当我运行:
import tensorflow_model_optimization as tfmot
字符串
我得到了以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\__init__.py", line 86, in <module>
from tensorflow_model_optimization.python.core.api import clustering
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\api\__init__.py", line 16, in <module>
from tensorflow_model_optimization.python.core.api import clustering
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\api\clustering\__init__.py", line 16, in
<module>
from tensorflow_model_optimization.python.core.api.clustering import keras
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\api\clustering\keras\__init__.py", line 19,
in <module>
from tensorflow_model_optimization.python.core.clustering.keras.cluster import cluster_scope
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\clustering\keras\cluster.py", line 20, in
<module>
from tensorflow_model_optimization.python.core.clustering.keras import cluster_wrapper
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\clustering\keras\cluster_wrapper.py", line
24, in <module>
from tensorflow_model_optimization.python.core.clustering.keras import clustering_registry
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\clustering\keras\clustering_registry.py",
line 57, in <module>
class ClusteringRegistry(object):
File "C:\Users\Asura\AppData\Local\Programs\Python\Python310\lib\site-
packages\tensorflow_model_optimization\python\core\clustering\keras\clustering_registry.py",
line 92, in ClusteringRegistry
tf.keras.experimental.PeepholeLSTMCell,
AttributeError: module 'keras.api._v2.keras.experimental' has no attribute 'PeepholeLSTMCell'
型
我在不同的OS-es和不同的python版本上都有这个错误。我怀疑这是一些tf包的版本错误。我用途:
tensorflow 2.9.1
tensorflow-addons 0.16.1
tensorflow-estimator 2.9.0
tensorflow-hub 0.12.0
tensorflow-io 0.23.1
tensorflow-io-gcs-filesystem 0.23.1
tensorflow-model-optimization 0.7.1
型
2条答案
按热度按时间thtygnil1#
我成功地导入了
tensorflow_model_optimization
在我的环境中具有以下版本:字符串
与Tensorflow相关,我有额外的包:
型
希望这对你有帮助!
wooyq4lh2#
确保您首先安装了tensorflow_model_optimization库
字符串
然后运行:
型
也请确保升级keras版本
型