【问题标题】:How to find the Input and Output Nodes of a Frozen Model如何找到冻结模型的输入和输出节点
【发布时间】:2018-06-20 22:53:49
【问题描述】:

我想在模型动物园的冻结模型上使用 tensorflow 的 optimize_for_inference.py 脚本:ssd_mobilenet_v1_coco

如何查找/确定模型的输入和输出名称?

Here is a link to the graph generated by tensorboard

这个问题可能会有所帮助:Given a tensor flow model graph, how to find the input node and output node names(对我来说没有)

【问题讨论】:

    标签: tensorflow inference object-detection-api


    【解决方案1】:

    我认为您可以使用以下代码。我从here 下载了ssd_mobilenet_v1_coco 冻结模型,并能够获得如下所示的输入和输出名称

    !pip install tensorflow==1.15.5
    
    import tensorflow as tf
    tf.__version__ # TF1.15.5
    
    gf = tf.GraphDef()  
    m_file = open('/content/frozen_inference_graph.pb','rb')
    gf.ParseFromString(m_file.read())
     
    with open('somefile.txt', 'a') as the_file:
       for n in gf.node:
           the_file.write(n.name+'\n')
     
    file = open('somefile.txt','r')
    data = file.readlines()
    print("output name = ")
    print(data[len(data)-1])
     
    print("Input name = ")
    file.seek ( 0 )
    print(file.readline())
    

    输出是

    output name = 
    detection_classes
    
    Input name = 
    image_tensor
    

    请查看gist here

    【讨论】:

      猜你喜欢
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      • 2018-12-09
      • 2020-10-11
      • 2021-11-01
      • 2015-08-13
      相关资源
      最近更新 更多