【问题标题】:AttributeError: NDARRAY_SPEC while importing tensorflowAttributeError: NDARRAY_SPEC 在导入 tensorflow 时
【发布时间】:2020-11-11 14:09:34
【问题描述】:

我收到此错误

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

screenshot

【问题讨论】:

  • 我在 win 10 20H2 和 python 3.8.5 上遇到此错误

标签: python tensorflow deep-learning jupyter-notebook


【解决方案1】:

原因是你的tensorflow版本和你的python版本不兼容。

请参阅this page 了解兼容版本。

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

      • 请不要在多个旧问题上发布相同的答案。将它们标记为重复
      • 我想这样做,但不幸的是,没有一个问题得到接受或赞成的答案。因此,我无法将它们标记为重复。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-22
      • 2022-06-23
      • 2017-08-30
      相关资源
      最近更新 更多