在我的jupyter笔记本中,我试图导入tensorflow并出现错误

时间:2020-11-11 14:09:34

标签: python tensorflow deep-learning jupyter-notebook

我收到此错误

AttributeError: type object 'TypeSpecProto' has no attribute 
'NDARRAY_SPEC'

screenshot

3 个答案:

答案 0 :(得分:0)

原因是您的tensorflow版本与python版本不兼容。

有关了解兼容版本,请参阅this page

答案 1 :(得分:0)

您需要将导入移动到 tensorflow.keras 域。例如:

from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import Dense, Activation, concatenate, Input, Embedding
from tensorflow.keras.layers import Reshape, Concatenate, BatchNormalization, Dropout, Add, Lambda
from tensorflow.keras.layers import add
from tensorflow.keras.optimizers import Adam, RMSprop
from tensorflow.keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor

答案 2 :(得分:0)

对我来说解决这个问题的唯一方法是卸载包 tensorflow tensorboard 和 numpy 并通过执行以下操作通过 pip 重新安装它们:

pip uninstall numpy tensorflow tensorboard
pip install --user --upgrade tensorflow