【问题标题】:Convert tensorflow model(.pb) to coreml(.mlmodel)将 tensorflow 模型(.pb)转换为 coreml(.mlmodel)
【发布时间】:2018-09-12 09:24:03
【问题描述】:

ValueError: 在 TF 图中找不到产生给定输出名称的操作

对 ML/Tensorflow 和 Python 完全陌生。

我正在尝试将模型从 .pb 格式转换为 .mlmodel 格式以用于 ios 项目。 我正在使用 tf-coreml。

>>> tf_converter.convert(tf_model_path = '/Users/anup/Downloads/inception_v1_2016_08_28_frozen.pb/inception_v1_2016_08_28_frozen.pb',mlmodel_path = '/Users/anup/Downloads/inception_v1_2016_08_28_frozen.pb/inception_v1_2016_08_28_frozen.mlmodel',output_feature_names = ['Softmax:0'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tfcoreml/_tf_coreml_converter.py", line 493, in convert
    predicted_probabilities_output=predicted_probabilities_output)
  File "tfcoreml/_tf_coreml_converter.py", line 157, in _convert_pb_to_mlmodel
    OPS, skip_ops = _topological_sort_ops(OPS, output_feature_names) # do (1),(2),(3) listed above
  File "tfcoreml/_tf_graph_transform.py", line 134, in _topological_sort_ops
    skip_ops = _find_skippable_ops(G, ops, output_names)
  File "tfcoreml/_tf_graph_transform.py", line 72, in _find_skippable_ops
    raise ValueError('No op found in the TF graph that produces the given output name(s)')
ValueError: No op found in the TF graph that produces the given output name(s)
>>> 

我在 mac 终端上运行它。 实际上我不知道 Softmax:0 是什么意思以及我是否需要用其他东西替换它。按照这个:https://github.com/tf-coreml/tf-coreml 这可能是一件非常简单的事情而且我很愚蠢。请帮我解决这个问题。

【问题讨论】:

    标签: python tensorflow machine-learning deep-learning coreml


    【解决方案1】:

    Softmax:0 是张量的名称。您的图表似乎没有具有该名称的张量。

    找到图表中最后一个张量名称的一种方法是到download Netron 并使用它来查看.pb 文件。

    【讨论】:

    • 我转换了以下文件:hackernoon.com/… 但是当我导入到 ios 项目时,它不接受图像。
    • 我认为最后一个张量图:559:op name = import/final_result,op type = (Softmax),inputs = import/final_training_ops/Wx_plus_b/add:0,outputs = import/final_result:0 @ 输入形状:name = import/final_training_ops/Wx_plus_b/add:0 : (?, 5) @ 输出形状:name = import/final_result:0 : (?, 5)
    猜你喜欢
    • 2019-12-18
    • 2020-05-23
    • 2019-11-28
    • 2019-05-22
    • 2020-08-25
    • 2020-11-17
    • 2020-03-31
    • 2020-08-19
    • 1970-01-01
    相关资源
    最近更新 更多