【问题标题】:Tensorflow - Errors in converting .pbtxt model to .tfliteTensorflow - 将 .pbtxt 模型转换为 .tflite 时出错
【发布时间】:2018-08-17 19:45:11
【问题描述】:

我正在尝试一个汽车评估分类的例子 http://archive.ics.uci.edu/ml/datasets/Car+Evaluation

我已成功训练模型并成功打印预测 使用以下code

我正在关注这个page 将.pb 模型转换为.tflite

我已经成功构建了冻结图

bazel build tensorflow/python/tools:freeze_graph

现在我在运行以下命令时遇到问题

bazel-bin/tensorflow/python/tools/freeze_graph\
    --input_graph=/CarEvaluation/mobilenet_v1_224.pb \
    --input_checkpoint=/CarEvaluation/checkpoints/mobilenet-10202.ckpt \
    --input_binary=true --output_graph=/CarEvaluation/frozen_mobilenet_v1_224.pb \
    --output_node_names=CarEvaluation/Predictions/Reshape_1

问题是在模型目录中我有.pbtxt 文件而不是.pb 而且我在模型目录中找不到.ckpt 文件,我有一个简单的检查点文件和几个.ckpt 元和索引文件,后缀为一些数字。

我尝试使用 .pbtxt 文件运行上述命令,但出现此异常

   input_graph_def.ParseFromString(f.read())
google.protobuf.message.DecodeError: Error parsing message

【问题讨论】:

    标签: python tensorflow machine-learning classification


    【解决方案1】:

    使用 .pbtxt 和最高编号的 .ckpt

    即类似:

    bazel-bin/tensorflow/python/tools/freeze_graph\
        --input_graph=/CarEvaluation/mobilenet_v1_224.pbtxt \
        --input_checkpoint=/CarEvaluation/checkpoints/mobilenet-10202.ckpt-2000 \
        --input_binary=true --output_graph=/CarEvaluation/frozen_mobilenet_v1_224.pb \
        --output_node_names=CarEvaluation/Predictions/Reshape_1
    

    【讨论】:

      【解决方案2】:

      据我从 freeze_graph 代码中了解到,当您想将其与 pbtxt 文件一起使用时,您需要省略 --input_binary=true 选项,因为输入文件不再是二进制文件。

      【讨论】:

        猜你喜欢
        • 2023-01-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-06
        • 1970-01-01
        • 2020-12-03
        • 1970-01-01
        • 2020-09-10
        相关资源
        最近更新 更多