我得到一个错误,当我导入TensorFlow。我试着重新安装它,但仍然,我一直得到这个错误->TypeError:无法将函数返回值转换为Python类型!签名是()->处理。
import tensorflow as tf
from tensorflow.keras.layers import Add, Input, Dense, Dropout
from tensorflow.keras.layers import BatchNormalization, Embedding
from tensorflow.keras.layers import Flatten, Concatenate
from tensorflow.keras import regularizers
from keras.regularizers import l1
from keras.regularizers import l2
from tensorflow.keras import regularizers
from keras.models import Sequential
from keras.wrappers.scikit_learn import KerasClassifier
运行pip3 install numpy --upgrade
解决了这个问题。
对于我来说,来自TensorFlow的第一个错误是
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
表示NumPy版本不匹配。
因此,将NumPy降级到1.21.6应该可以解决这个问题:
pip install numpy==1.21.6
没有任何帮助,除了将tensorflow-metal降级到v.0.6.0:
"pandas>=2.0.0",
"ipykernel>=6.22.0",
"tensorflow-macos>=2.10.0",
"tensorflow-metal==0.6.0",
"openpyxl>=3.1.2",
"plotly>=5.14.1",
"matplotlib>=3.7.1",
"scikit-learn>=1.2.2",
"keras>=2.10.0",
"keras-self-attention>=0.51.0",
"numpy~=1.24",
requirements -python = ">=3.9">