python tensorflow -无法将原始文件构建到描述符池中

eqoofvh9  于 2022-12-25  发布在  Python
关注(0)|答案(1)|浏览(315)

我安装了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.

我做错了什么?

3bygqnnd

3bygqnnd1#

这段代码在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

相关问题