简体   繁体   English

尝试使用toco转换TF模型时出错

[英]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.

相关问题 在运行toco时尝试将TensorFlow模型转换为TensorFlow lite --help给我一个错误 - Trying to convert TensorFlow model to TensorFlow lite, when running toco --help gives me an error 使用toco将Frozen_pb文件转换为tflite文件时出错 - Error when I convert the frozen_pb file to tflite file using toco 如何获取TOCO tf_convert的冻结Tensorflow模型的input_shape - How do i get the input_shape of a frozen Tensorflow-Model for TOCO tf_convert Tensorflow [Toco]将模型转换为优化格式导致ValueError - Tensorflow [Toco] convert Model to optimized format cause ValueError 使用tf.saved_model.simple_save()时出错 - Error when using tf.saved_model.simple_save() 将 tf model 转换为 TFlite model 时出错 - Error when converting a tf model to TFlite model 无法从tf.keras模型 - &gt;量化的冻结图 - &gt; .tflite与TOCO - Unable to go from tf.keras model -> quantized frozen graph -> .tflite with TOCO 由于权限被拒绝错误,无法使用toco(编译器来优化TF模型) - Unable to use toco (the compiler to optimize tf models) due to permission denied error 在Ubuntu 16.04上使用bazel从源构建张量流。 错误是---&gt;规则&#39;// tensorflow / contrib / lite / toco:toco&#39;的链接失败(出口1) - Building tensor flow from source using bazel on Ubuntu 16.04. Error is ---> Linking of rule '//tensorflow/contrib/lite/toco:toco' failed (Exit 1) 使用 tf2onnx 将 TensorFlow Model 转换为 Python 内的 ONNX - Convert TensorFlow Model to ONNX within Python using tf2onnx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM