如何查看tensorflow lite toco编译时的各个参数

https://github.com/tensorflow/models/issues/8148#issuecomment-641028423

想生成tflite格式的模型,用于安卓端做推理的时候,不知道toco需要指定哪些参数,所以另写一篇文章放在这里。

usage下列出了所有参数,后面对参数含义做了详细说明。usage中列有很多参数,--***是我们输入命令行时的参数,以下为例:

--output_file=""
command:
# tflite_convert -h

usage: tflite_convert [-h] --output_file OUTPUT_FILE
                      (--graph_def_file GRAPH_DEF_FILE | --saved_model_dir SAVED_MODEL_DIR | --keras_model_file KERAS_MODEL_FILE)
                      [--output_format {TFLITE,GRAPHVIZ_DOT}]
                      [--inference_type {FLOAT,QUANTIZED_UINT8}]
                      [--inference_input_type {FLOAT,QUANTIZED_UINT8}]
                      [--input_arrays INPUT_ARRAYS]
                      [--input_shapes INPUT_SHAPES]
                      [--output_arrays OUTPUT_ARRAYS]
                      [--saved_model_tag_set SAVED_MODEL_TAG_SET]
                      [--saved_model_signature_key SAVED_MODEL_SIGNATURE_KEY]
                      [--std_dev_values STD_DEV_VALUES]
                      [--mean_values MEAN_VALUES]
                      [--default_ranges_min DEFAULT_RANGES_MIN]
                      [--default_ranges_max DEFAULT_RANGES_MAX]
                      [--post_training_quantize] [--drop_control_dependency]
                      [--reorder_across_fake_quant]
                      [--change_concat_input_ranges {TRUE,FALSE}]
                      [--allow_custom_ops]
                      [--converter_mode {DEFAULT,TOCO_FLEX,TOCO_FLEX_ALL}]
                      [--dump_graphviz_dir DUMP_GRAPHVIZ_DIR]
                      [--dump_graphviz_video]

Command line tool to run TensorFlow Lite Optimizing Converter (TOCO).

optional arguments:
  -h, --help            show this help message and exit
  --output_file OUTPUT_FILE
                        Full filepath of the output file.
  --graph_def_file GRAPH_DEF_FILE
                        Full filepath of file containing frozen TensorFlow
                        GraphDef.
  --saved_model_dir SAVED_MODEL_DIR
                        Full filepath of directory containing the SavedModel.
  --keras_model_file KERAS_MODEL_FILE
                        Full filepath of HDF5 file containing tf.Keras model.
  --output_format {TFLITE,GRAPHVIZ_DOT}
                        Output file format.
  --inference_type {FLOAT,QUANTIZED_UINT8}
                        Target data type of real-number arrays in the output
                        file.
  --inference_input_type {FLOAT,QUANTIZED_UINT8}
                        Target data type of real-number input arrays. Allows
                        for a different type for input arrays in the case of
                        quantization.
  --input_arrays INPUT_ARRAYS
                        Names of the input arrays, comma-separated.
  --input_shapes INPUT_SHAPES
                        Shapes corresponding to --input_arrays, colon-
                        separated.
  --output_arrays OUTPUT_ARRAYS
                        Names of the output arrays, comma-separated.
  --saved_model_tag_set SAVED_MODEL_TAG_SET
                        Comma-separated set of tags identifying the
                        MetaGraphDef within the SavedModel to analyze. All
                        tags must be present. (default "serve")
  --saved_model_signature_key SAVED_MODEL_SIGNATURE_KEY
                        Key identifying the SignatureDef containing inputs and
                        outputs. (default DEFAULT_SERVING_SIGNATURE_DEF_KEY)
  --std_dev_values STD_DEV_VALUES
                        Standard deviation of training data for each input
                        tensor, comma-separated floats. Used for quantized
                        input tensors. (default None)
  --mean_values MEAN_VALUES
                        Mean of training data for each input tensor, comma-
                        separated floats. Used for quantized input tensors.
                        (default None)
  --default_ranges_min DEFAULT_RANGES_MIN
                        Default value for min bound of min/max range values
                        used for all arrays without a specified range,
                        Intended for experimenting with quantization via
                        "dummy quantization". (default None)
  --default_ranges_max DEFAULT_RANGES_MAX
                        Default value for max bound of min/max range values
                        used for all arrays without a specified range,
                        Intended for experimenting with quantization via
                        "dummy quantization". (default None)
  --post_training_quantize
                        Boolean indicating whether to quantize the weights of
                        the converted float model. Model size will be reduced
                        and there will be latency improvements (at the cost of
                        accuracy). (default False)
  --drop_control_dependency
                        Boolean indicating whether to drop control
                        dependencies silently. This is due to TensorFlow not
                        supporting control dependencies. (default True)
  --reorder_across_fake_quant
                        Boolean indicating whether to reorder FakeQuant nodes
                        in unexpected locations. Used when the location of the
                        FakeQuant nodes is preventing graph transformations
                        necessary to convert the graph. Results in a graph
                        that differs from the quantized training graph,
                        potentially causing differing arithmetic behavior.
                        (default False)
  --change_concat_input_ranges {TRUE,FALSE}
                        Boolean to change behavior of min/max ranges for
                        inputs and outputs of the concat operator for
                        quantized models. Changes the ranges of concat
                        operator overlap when true. (default False)
  --allow_custom_ops    Boolean indicating whether to allow custom operations.
                        When false any unknown operation is an error. When
                        true, custom ops are created for any op that is
                        unknown. The developer will need to provide these to
                        the TensorFlow Lite runtime with a custom resolver.
                        (default False)
  --converter_mode {DEFAULT,TOCO_FLEX,TOCO_FLEX_ALL}
                        Experimental flag, subject to change. ConverterMode
                        indicating which converter to use. (default
                        ConverterMode.DEFAULT)
  --dump_graphviz_dir DUMP_GRAPHVIZ_DIR
                        Full filepath of folder to dump the graphs at various
                        stages of processing GraphViz .dot files. Preferred
                        over --output_format=GRAPHVIZ_DOT in order to keep the
                        requirements of the output file.
  --dump_graphviz_video
                        Boolean indicating whether to dump the graph after
                        every graph transformation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

聿默

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值