【问题标题】:Error when attempting to convert TF model using toco尝试使用 toco 转换 TF 模型时出错
【发布时间】:2018-04-29 23:03:27
【问题描述】:

我有一个 TF 模型,我需要将其转换为 int8 以便在嵌入式设备中实现。我正在尝试使用 toco 对其进行转换,但我无法确定如何使用输入参数正确实例化 toco:

<USER>:~/.local/bin$ python3 toco \
>   --input_file=<PATH>/frozen_graph.pb \
>   --output_file=<PATH>/tflite_graph.tflite \
>   --input_format=TENSORFLOW_GRAPHDEF \
>   --output_format=TFLITE \
>   --inference_type=QUANTIZED_UINT8 \
>   --output_arrays=Sidmoid \
>   --input_arrays=IteratorGetNext \
>   --input_shapes=1:16:16:1 \
>   --mean_values=128 \
>   --std_values=127
WARNING:tensorflow:From <USER>.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
2018-04-27 11:40:33.699249: F tensorflow/contrib/lite/toco/model_cmdline_flags.cc:240] Check failed: mean_values.size() == model_flags->input_arrays_size() 
Aborted (core dumped)

我了解mean_values 输入 arg 存在问题,但我不了解以下各项的预期用途:

--mean_values="" string mean_values parameter for image models, comma-separated list of doubles, used to compute input activations from input pixel data. Each entry in the list should match an entry in --input_arrays.

我也尝试过",128,128,",因为我的解释是您不希望批量大小/通道暗淡的平均值,但文档说它需要列表中每个输入的输入应该匹配input_arrays 中的元素。

我也不确定为 input_arrays arg 放置什么,因为我看到的大多数代码示例都只使用 input,但对我来说,您似乎需要图中节点的名称。

我想我在这里误解了一些东西,但我似乎无法弄清楚。任何帮助将不胜感激!

【问题讨论】:

    标签: python tensorflow tensorflow-lite


    【解决方案1】:

    对于任何想知道的人来说,让我有点困惑的是文档:它说“Input_shapes”是一个字符串“对应于--input_arrays的形状,冒号分隔......”但是尺寸仍然应该用逗号分隔:

    bazel-bin/third_party/tensorflow/contrib/lite/toco/toco \
      --input_file=<my_path>/frozen_eval_graph.pb \
      --output_file=<my_path>/tflite_graph.tflite \
      --input_format=TENSORFLOW_GRAPHDEF \
      --output_format=TFLITE \
      --inference_type=QUANTIZED_UINT8 \
      --output_arrays=Sigmoid \
      --input_arrays=Reshape \
      --input_shapes=1,16,16,1 \
      --mean_values=128 \
      --std_values=127 \
      --variable_batch=true
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-27
      相关资源
      最近更新 更多