[英]Error when attempting to convert TF model using toco
I have a TF model which I need to convert to int8 for implementation in an embedded device. 我有一个TF模型,需要将其转换为int8才能在嵌入式设备中实现。 I am attempting to use toco to convert it, yet I am having trouble determining how to instantiate toco with the input args properly:
我正在尝试使用toco进行转换,但是我无法确定如何正确地使用输入args实例化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)
I understand there is an issue with the mean_values
input arg, however I don't understand the intended usage of: 我知道
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.
I have tried also ",128,128,"
, as my interpretation is that you wouldn't want a mean value for your batch size/channel dims, but the documentation says that it needs an input for each input in the list should match an element in input_arrays. 我也尝试过
",128,128,"
,因为我的解释是您不希望批次大小/通道",128,128,"
的平均值,但是文档说,列表中的每个输入都需要一个输入来匹配一个元素在input_arrays中。
I am also unsure what to put for the input_arrays
arg, as most places I've seen code examples just use input
but to me it seems you'd need the name of the node in the graph. 我也不确定为
input_arrays
arg放置什么,因为我在大多数地方看到的代码示例仅使用input
但对我来说似乎您需要图形中节点的名称。
I think I'm misunderstanding something here, but I just can't seem to figure it out. 我想我对这里有些误解,但我似乎无法弄清楚。 Any help would be appreciated!
任何帮助,将不胜感激!
For anyone wondering, it was the documentation that slightly confused me: It says that "Input_shapes" is a string of "Shapes corresponding to --input_arrays, colon separated..." however the dimensions should still be comma separated: 对于任何想知道的人,是文档使我有些困惑:它说“ 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.