AttributeError:NDARRAY\u导入tensorflow时的规范

2024-10-04 03:25:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我得到这个错误

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

screenshot


Tags: noobjecttype错误attributeattributeerrorhasndarray
3条回答

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

pip uninstall numpy tensorflow tensorboard
pip install  user  upgrade tensorflow

原因是tensorflow版本与python版本不兼容

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

您需要将导入移动到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

相关问题 更多 >