我正在使用one of the Deep Learning With Python notebooks(第二版)
当我在单元格1中运行以下代码时--
from tensorflow.keras import layers
model = keras.Sequential([
layers.Dense(64, activation="relu"),
layers.Dense(10, activation="softmax")
])
我立即得到这个错误,我不知道如何修复:
/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/dtypes.py:585:
FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
np.object,
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/tmp/ipykernel_1679/4031490511.py in <module>
----> 1 from tensorflow import keras
2 from tensorflow.keras import layers
3
4 model = keras.Sequential([
5 layers.Dense(64, activation="relu"),
...然后是一系列其他导入错误,然后是这个:
583 # strings.
584 types_pb2.DT_STRING:
--> 585 np.object,
586 types_pb2.DT_COMPLEX64:
587 np.complex64,
/usr/local/lib/python3.8/dist-packages/numpy/__init__.py in __getattr__(attr)
303
304 if attr in __former_attrs__:
--> 305 raise AttributeError(__former_attrs__[attr])
306
307 # Importing Tester requires importing all of UnitTest which is not a
AttributeError: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
然后我想也许我有一个旧版本的Keras,所以我首先查看了https://github.com/keras-team/keras/releases上的Keras更新日志,但我找不到任何与numpy或object有关的东西,所以我试图从终端获取我正在使用的版本:python3 -c 'import keras; print(keras.__version__)'
但它立即给了我同样的错误。
任何帮助赞赏!
1条答案
按热度按时间apeeds0o1#
尝试使用以下命令安装
numpy
版本1.23.4(这对我有效):