【问题标题】:How to deduce the output_node_names of a pretrained model?如何推断预训练模型的 output_node_names?
【发布时间】:2019-02-26 18:27:36
【问题描述】:

我正在尝试使用 Tensorflow.js 为我们转换一个预训练模型:

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md

我选择了mask_rcnn_inception_v2_coco

tensorflowjs_converter 需要特定的output_node_names。网络上的各种资源指向我使用 summarize_graph 等工具来帮助检查潜在的输出节点名称。

不幸的是,我在 Google Colab 上运行它,并且(据我所知)我无法安装 bazel,我需要从源代码构建 summarize_graph,我需要确定哪个 output_node_names传递给转换器。

我在这里遗漏了什么吗?有没有更直接的方法可以从现有的预训练模型转到 Tensorflow.js(用于在浏览器上进行推理)?

【问题讨论】:

    标签: tensorflow tensorflowjs-converter


    【解决方案1】:

    对于 mask_rcnn_inception_v2_coco_2018_01_28 的结果 bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph=frozen_inference_graph.pb

    Found 1 possible inputs: (name=image_tensor, type=uint8(4), shape=[?,?,?,3])
    No variables spotted.
    Found 5 possible outputs: (name=detection_boxes, op=Identity) (name=detection_scores, op=Identity) (name=detection_classes, op=Identity) (name=num_detections, op=Identity) (name=detection_masks, op=Identity) 
    

    【讨论】:

    • 谢谢。有没有办法在 Google colab 上运行 bazel?
    • 不,我认为你不能在 google colab 上运行 bazel,因为它不是一个功能齐全的 linux 机器。
    【解决方案2】:

    这篇文章帮助了我: https://developer.arm.com/technologies/machine-learning-on-arm/developer-material/how-to-guides/optimizing-neural-networks-for-mobile-and-embedded-devices-with-tensorflow/determine-the-names-of-input-and-output-nodes

    让 tensorboard 启动并运行(可以在 windows 或其他任何地方完成,这是一个 ubuntu 安装)

    pip install tensorboard
    

    >

    tensorboard --logdir=/tmp/tensorboard
    

    >

    python tensorflow/python/tools/import_pb_to_tensorboard.py --model_dir resnetv1_50.pb --log_dir /tmp/tensorboard
    

    (如果您没有 import_pb_to_tensorboard.py,您可以下载文件 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/import_pb_to_tensorboard.py 并指向您保存它的任何目录)

    您使用上述命令将模型导入您正在服务的张量板。在 tensorboard 中,您可以单击模型并查看最终输出的名称。我的叫“import/final_result”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 1970-01-01
      • 2023-01-03
      • 1970-01-01
      • 2022-10-19
      • 1970-01-01
      • 2019-08-16
      相关资源
      最近更新 更多