【问题标题】:Convert InceptionV3 pb file to tflite将 InceptionV3 pb 文件转换为 tflite
【发布时间】:2019-01-14 08:02:55
【问题描述】:

我正在尝试使用 TOCO 将 InceptionV3 模型从 pb 文件转换为 tflite 文件。我使用以下命令:

tflite_convert --output_file=/home/luca/Scrivania/prova.tflite --graph_def_file=/home/luca/Scrivania/inception_v3_2016_08_28_frozen.pb/inception_v3_2016_08_28_frozen.pb --input_arrays=input --output_arrays="InceptionV3/Predictions/Reshape_1:0"

但我收到以下错误:

ValueError: Invalid tensors 'InceptionV3/Predictions/Reshape_1:0' were found.

我该如何解决?

【问题讨论】:

    标签: tensorflow toco


    【解决方案1】:

    此错误表示您提供的output_array 不正确。一般来说,InceptionV3 模型的输出数组是InceptionV3/Predictions/Reshape

    如果这不起作用,下一步是在 TensorBoard 中可视化您的 TensorFlow .pb 模型并查找输出数组。

    【讨论】:

      【解决方案2】:

      如果你想知道 "--output_arrays=" 。在frozen_inference_graph.pb文件夹所在的位置创建一个python文件,然后将此代码粘贴到py中

      import tensorflow as tf
      gf = tf.GraphDef()
      m_file = open('tflite_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())
      

      运行文件后,它将显示 input_arrays 和 output_arrays。

      进一步的信息检查:How to convert .pb to TFLite format?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-05-08
        • 1970-01-01
        • 1970-01-01
        • 2018-12-09
        • 1970-01-01
        • 1970-01-01
        • 2019-03-25
        相关资源
        最近更新 更多