python - tensorflow - 无法将原型(prototype)文件构建到描述符池中

标签 python tensorflow keras artificial-intelligence resnet

我安装了 anaconda,创建了一个全新的环境并通过 pip 安装了 tensorflow。 然后我试了这个:

import tensorflow as tf

tf.keras.applications.ResNet152V2(
    include_top=True,
    weights="imagenet",
    input_tensor=None,
    input_shape=None,
    pooling=None,
    classes=1000,
    classifier_activation="softmax",
)

我直接得到了:

TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "tensorflow/python/framework/cpp_shape_inference.proto":
  tensorflow.CppShapeInferenceResult.HandleShapeAndType.specialized_type: ".tensorflow.SpecializedType" is not defined.

我做错了什么?

最佳答案

代码在 Google_colab 上运行良好

import tensorflow as tf
tf.keras.applications.resnet_v2.ResNet152V2(
    include_top=True, weights='imagenet', input_tensor=None,
    input_shape=None, pooling=None, classes=1000,
    classifier_activation='softmax'

) 输出

Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/resnet/resnet152v2_weights_tf_dim_ordering_tf_kernels.h5
242753536/242745792 [==============================] - 3s 0us/step
242761728/242745792 [==============================] - 3s 0us/step
<keras.engine.functional.Functional at 0x7faf1736c210>

问题在于 Protobuf 安装

pip uninstall protobuf
pip install --no-binary protobuf protobuf

关于python - tensorflow - 无法将原型(prototype)文件构建到描述符池中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68952308/

相关文章:

python - 使用可用库的子集为 iOS 编译 OpenCV 3.1.0

python - scikit-learn 分类器中的评分函数位于何处?

python - 使用相反顺序的两个元组条目对元组列表进行排序

python - 在 Tensorboard 的 mnist 示例中生成了意外层

php - 在 Web 应用程序中使用 TensorFlow 模型

python - 让需求直接指向 git 存储库而不是 PyPi 有什么好处?

c++ - Tensorflow 服务 : Large model, protobuf 错误

r - 当我尝试并行拟合多个模型时,为什么 tensorflow/keras 会窒息?

python - 模型不学习

deep-learning - 使用 Keras : simple way for faster R-CNN or YOLO 的对象检测