gpt4 book ai didi

tensorflow - 没有名为 'tensorflow.keras.layers.experimental.preprocessing' 的模块

转载 作者:行者123 更新时间:2023-12-03 15:23:52 25 4
gpt4 key购买 nike

代码下方

import numpy as np
np.random.seed(0)
from sklearn import datasets
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format ='retina'

from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SGD
在错误消息 下方
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\keras\__init__.py in <module>
2 try:
----> 3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
4 except ImportError:

ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental.preprocessing'

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
<ipython-input-5-943507dd87a6> in <module>
6 get_ipython().run_line_magic('config', "InlineBackend.figure_format ='retina'")
7
----> 8 from keras.models import Sequential
9 from keras.layers import Dense
10 from keras.optimizers import SGD

~\Anaconda3\lib\site-packages\keras\__init__.py in <module>
4 except ImportError:
5 raise ImportError(
----> 6 'Keras requires TensorFlow 2.2 or higher. '
7 'Install TensorFlow via `pip install tensorflow`')
8

ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow
注意:` 我认为,主要问题是 Tensorflow 版本。我使用了 somes 命令,如下所示,
conda create -n tf tensorflow
conda activate tf
我还使用了以下命令
conda create -n tf-gpu tensorflow-gpu
conda activate tf-gpu
但它不起作用,请帮助解决错误。

最佳答案

您需要更新 TensorFlow 的版本。对我来说,2.2.0 解决了这个问题。我还检查了更高版本并且工作正常。

pip install tensorflow==2.2.0
或者
pip install tensorflow-gpu==2.2.0 

关于tensorflow - 没有名为 'tensorflow.keras.layers.experimental.preprocessing' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63542803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com