I have a TF model which I need to convert to int8 for implementation in an embedded device. I am attempting to use toco to convert it, yet I am having trouble determining how to instantiate toco with the input args properly:
<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="" 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.
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.
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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.