You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将TensorFlow(.pb)模型转CoreML(.mlmodel)时遇ValueError报错求助

Fixing "ValueError: No op found in the TF graph that produces the given output name(s)" when converting PB to MLModel

Hey there! I’ve helped many folks work through this exact error with tf-coreml, so let’s get your Inception v1 model converted for iOS in no time. This error happens because the converter can’t locate the specific output node it needs to export from your TensorFlow graph—here’s how to fix it step by step:

Step 1: Identify your model’s actual output node names

First, you need to find out what output nodes exist in your frozen PB file. Pre-trained models like Inception v1 don’t always use the "default" output names the converter assumes. Run this quick Python script to list all nodes in your graph:

import tensorflow as tf

def list_all_graph_nodes(pb_file_path):
    # Load the frozen graph
    with tf.io.gfile.GFile(pb_file_path, 'rb') as f:
        graph_def = tf.compat.v1.GraphDef()
        graph_def.ParseFromString(f.read())
    
    # Print all node names
    print("All nodes in the TF graph:")
    for node in graph_def.node:
        print(node.name)

Call this function with your PB path:

list_all_graph_nodes('/Users/anup/Downloads/inception_v1_2016_08_28_frozen.pb/inception_v1_2016_08_28_frozen.pb')

Look for nodes that sound like output layers—for Inception v1, this is usually something like InceptionV1/Logits/Predictions/Reshape_1 or softmax.

Step 2: Convert with explicit output feature names

Once you have the correct output node name, you need to tell tf-coreml exactly where to pull the output from. Important note: TensorFlow uses node_name:0 to refer to the first tensor output of a node, so you’ll need to add that suffix.

Update your conversion code to include the output_feature_names parameter:

import tf_coreml as tf_converter

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_converted.mlmodel',
    output_feature_names=['InceptionV1/Logits/Predictions/Reshape_1:0']  # Replace with your found node name + :0
)

Step 3: Double-check for common pitfalls

  • Verify the node exists: Make sure the name you’re using matches exactly what the script printed—typos or missing suffixes (:0) are the #1 cause of this error.
  • Update tf-coreml: Older versions might have compatibility issues with certain TensorFlow ops. Run pip install --upgrade tf-coreml to get the latest release.
  • Check input names (if needed): If you hit another error later, you might also need to specify input_feature_names—but start with fixing the output first.

This should resolve the "no op found" error and get your MLModel ready for your iOS project.

内容的提问来源于stack exchange,提问作者Anup G Prasad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:09:16