mace icon indicating copy to clipboard operation
mace copied to clipboard

mobilenetv2 Quantization-aware training model 转换出错

Open wcfzl opened this issue 5 years ago • 7 comments

Before you open an issue, please make sure you have tried the following steps:

  1. Make sure your environment is the same with (https://mace.readthedocs.io/en/latest/installation/env_requirement.html).
  2. Have you ever read the document for your usage?
  3. Check if your issue appears in HOW-TO-DEBUG or FAQ.
  4. The form below must be filled.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • NDK version(e.g., 15c):
  • GCC version(if compiling for host, e.g., 5.4.0):
  • MACE version (Use the command: git describe --long --tags):
  • Python version(2.7):
  • Bazel version (e.g., 0.13.0):

Model deploy file (*.yml)

target_abis: [arm64-v8a,armeabi-v7a]
model_graph_format: file
model_data_format: file
models:
  mobilenet_v2_quantize_retrain:
    platform: tensorflow
    model_file_path: ./frozen_eval_graph.pb
    model_sha256_checksum: 77b9c13bfa5691dc78b5ed409ce1c3c2041bd7208075513bf872b9877c617d00
    subgraphs:
      - input_tensors:
          - input_data
        input_shapes:
          - 1,321,321,3
        input_ranges:
          - -1.0,1.0
        output_tensors:
          - Output
        output_shapes:
          - 1,321,321
    runtime: cpu
    limit_opencl_kernel_time: 0
    nnlib_graph_mode: 0
    obfuscate: 0
    winograd: 0
    quantize: 1

Describe the problem

尝试转换Quantization-aware training model,但是发现无法转换mace(可以正常转换tflite) 从tensorflow官方(https://github.com/tensorflow/tensorflow/blob/r1.12/tensorflow/contrib/lite/g3doc/models.md)下载量化模型依然无法转换 mace提供的例子可以正常转换 对比pb模型发现例子中的pb模型中的kernel已经做了处理,融合了quantize min max 参数 mace sample: image tensorflow offical model: image

请问这一步是在哪里做处理的? thank you!

To Reproduce

Steps to reproduce the problem: training fellowing https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/quantize

Error information / logs

Please include the full log and/or traceback here.

WARNING: Logging before flag parsing goes to stderr.
W0725 12:43:48.382000 140301456430848 deprecation_wrapper.py:119] From /home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/tensorflow_converter.py:281: The name tf.GraphDef is deprecated. Please use tf.compat.v1.GraphDef instead.

W0725 12:43:48.383025 140301456430848 deprecation_wrapper.py:119] From /home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/tensorflow_converter.py:282: The name tf.gfile.Open is deprecated. Please use tf.io.gfile.GFile instead.

Run transform_graph: ['strip_unused_nodes', 'remove_nodes(op=Identity, op=CheckNumerics)', 'fold_constants(ignore_errors=true)', 'fold_batch_norms', 'fold_old_batch_norms', 'remove_control_dependencies', 'strip_unused_nodes', 'sort_by_execution_order']
('output keys: ', ['Output'])
W0725 12:43:49.221991 140301456430848 deprecation_wrapper.py:119] From /home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/tensorflow_converter.py:310: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0725 12:43:49.983136 140301456430848 deprecation_wrapper.py:119] From /home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/tensorflow_converter.py:318: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

Transform fake quantize
Remove identity: MobilenetV2/Conv/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_1/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_1/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_1/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_2/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_2/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_2/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_2/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_3/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_3/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_3/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_4/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_4/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_4/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_4/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_5/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_5/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_5/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_5/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_6/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_6/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_6/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_7/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_7/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_7/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_7/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_8/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_8/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_8/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_8/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_9/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_9/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_9/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_9/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_10/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_10/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_10/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_11/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_11/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_11/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_11/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_12/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_12/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_12/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_12/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_13/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_13/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_13/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_14/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_14/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_14/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_15/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_15/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_15/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_16/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: MobilenetV2/expanded_conv_16/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: aspp0/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: image_pooling/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: concat_projection/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Remove identity: logits/semantic/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity)
Rearrange batch to space: MobilenetV2/expanded_conv_14/depthwise/depthwise/BatchToSpaceND(BatchToSpaceND)
Rearrange batch to space: MobilenetV2/expanded_conv_15/depthwise/depthwise/BatchToSpaceND(BatchToSpaceND)
Rearrange batch to space: MobilenetV2/expanded_conv_16/depthwise/depthwise/BatchToSpaceND(BatchToSpaceND)
Fold biasadd: logits/semantic/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/Conv/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_1/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_1/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_2/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_2/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_3/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_3/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_4/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_4/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_5/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_5/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_6/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_6/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_7/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_7/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_8/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_8/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_9/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_9/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_10/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_10/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_11/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_11/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_12/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_12/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_13/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_13/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_14/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_14/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_15/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_15/depthwise/depthwise(DepthwiseConv2d)
Fold activation: MobilenetV2/expanded_conv_16/expand/conv2d/Conv2D(Conv2D)
Fold activation: MobilenetV2/expanded_conv_16/depthwise/depthwise(DepthwiseConv2d)
Fold activation: aspp0/conv2d/Conv2D(Conv2D)
Fold activation: image_pooling/conv2d/Conv2D(Conv2D)
Fold activation: concat_projection/conv2d/Conv2D(Conv2D)
Transpose filters to OHWI
Add OpenCL informations
Sort by execution
Final ops:
MobilenetV2/Conv/Relu6 (Conv2D, index:0): [[1L, 161L, 161L, 32L]]
MobilenetV2/expanded_conv/depthwise/Relu6 (DepthwiseConv2d, index:1): [[1L, 161L, 161L, 32L]]
MobilenetV2/expanded_conv/project/conv2d/Conv2D (Conv2D, index:2): [[1L, 161L, 161L, 16L]]
MobilenetV2/expanded_conv_1/expand/Relu6 (Conv2D, index:3): [[1L, 161L, 161L, 96L]]
MobilenetV2/expanded_conv_1/depthwise/Relu6 (DepthwiseConv2d, index:4): [[1L, 81L, 81L, 96L]]
MobilenetV2/expanded_conv_1/project/conv2d/Conv2D (Conv2D, index:5): [[1L, 81L, 81L, 24L]]
MobilenetV2/expanded_conv_2/expand/Relu6 (Conv2D, index:6): [[1L, 81L, 81L, 144L]]
MobilenetV2/expanded_conv_2/depthwise/Relu6 (DepthwiseConv2d, index:7): [[1L, 81L, 81L, 144L]]
MobilenetV2/expanded_conv_2/project/conv2d/Conv2D (Conv2D, index:8): [[1L, 81L, 81L, 24L]]
MobilenetV2/expanded_conv_2/add (Eltwise, index:9): [[1L, 81L, 81L, 24L]]
MobilenetV2/expanded_conv_3/expand/Relu6 (Conv2D, index:10): [[1L, 81L, 81L, 144L]]
MobilenetV2/expanded_conv_3/depthwise/Relu6 (DepthwiseConv2d, index:11): [[1L, 41L, 41L, 144L]]
MobilenetV2/expanded_conv_3/project/conv2d/Conv2D (Conv2D, index:12): [[1L, 41L, 41L, 32L]]
MobilenetV2/expanded_conv_4/expand/Relu6 (Conv2D, index:13): [[1L, 41L, 41L, 192L]]
MobilenetV2/expanded_conv_4/depthwise/Relu6 (DepthwiseConv2d, index:14): [[1L, 41L, 41L, 192L]]
MobilenetV2/expanded_conv_4/project/conv2d/Conv2D (Conv2D, index:15): [[1L, 41L, 41L, 32L]]
MobilenetV2/expanded_conv_4/add (Eltwise, index:16): [[1L, 41L, 41L, 32L]]
MobilenetV2/expanded_conv_5/expand/Relu6 (Conv2D, index:17): [[1L, 41L, 41L, 192L]]
MobilenetV2/expanded_conv_5/depthwise/Relu6 (DepthwiseConv2d, index:18): [[1L, 41L, 41L, 192L]]
MobilenetV2/expanded_conv_5/project/conv2d/Conv2D (Conv2D, index:19): [[1L, 41L, 41L, 32L]]
MobilenetV2/expanded_conv_5/add (Eltwise, index:20): [[1L, 41L, 41L, 32L]]
MobilenetV2/expanded_conv_6/expand/Relu6 (Conv2D, index:21): [[1L, 41L, 41L, 192L]]
MobilenetV2/expanded_conv_6/depthwise/Relu6 (DepthwiseConv2d, index:22): [[1L, 21L, 21L, 192L]]
MobilenetV2/expanded_conv_6/project/conv2d/Conv2D (Conv2D, index:23): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_7/expand/Relu6 (Conv2D, index:24): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_7/depthwise/Relu6 (DepthwiseConv2d, index:25): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_7/project/conv2d/Conv2D (Conv2D, index:26): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_7/add (Eltwise, index:27): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_8/expand/Relu6 (Conv2D, index:28): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_8/depthwise/Relu6 (DepthwiseConv2d, index:29): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_8/project/conv2d/Conv2D (Conv2D, index:30): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_8/add (Eltwise, index:31): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_9/expand/Relu6 (Conv2D, index:32): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_9/depthwise/Relu6 (DepthwiseConv2d, index:33): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_9/project/conv2d/Conv2D (Conv2D, index:34): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_9/add (Eltwise, index:35): [[1L, 21L, 21L, 64L]]
MobilenetV2/expanded_conv_10/expand/Relu6 (Conv2D, index:36): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_10/depthwise/Relu6 (DepthwiseConv2d, index:37): [[1L, 21L, 21L, 384L]]
MobilenetV2/expanded_conv_10/project/conv2d/Conv2D (Conv2D, index:38): [[1L, 21L, 21L, 96L]]
MobilenetV2/expanded_conv_11/expand/Relu6 (Conv2D, index:39): [[1L, 21L, 21L, 576L]]
MobilenetV2/expanded_conv_11/depthwise/Relu6 (DepthwiseConv2d, index:40): [[1L, 21L, 21L, 576L]]
MobilenetV2/expanded_conv_11/project/conv2d/Conv2D (Conv2D, index:41): [[1L, 21L, 21L, 96L]]
MobilenetV2/expanded_conv_11/add (Eltwise, index:42): [[1L, 21L, 21L, 96L]]
MobilenetV2/expanded_conv_12/expand/Relu6 (Conv2D, index:43): [[1L, 21L, 21L, 576L]]
MobilenetV2/expanded_conv_12/depthwise/Relu6 (DepthwiseConv2d, index:44): [[1L, 21L, 21L, 576L]]
MobilenetV2/expanded_conv_12/project/conv2d/Conv2D (Conv2D, index:45): [[1L, 21L, 21L, 96L]]
MobilenetV2/expanded_conv_12/add (Eltwise, index:46): [[1L, 21L, 21L, 96L]]
MobilenetV2/expanded_conv_13/expand/Relu6 (Conv2D, index:47): [[1L, 21L, 21L, 576L]]
MobilenetV2/expanded_conv_13/depthwise/Relu6 (DepthwiseConv2d, index:48): [[1L, 21L, 21L, 576L]]
MobilenetV2/expanded_conv_13/project/conv2d/Conv2D (Conv2D, index:49): [[1L, 21L, 21L, 160L]]
MobilenetV2/expanded_conv_14/expand/Relu6 (Conv2D, index:50): [[1L, 21L, 21L, 960L]]
MobilenetV2/expanded_conv_14/depthwise/depthwise/SpaceToBatchND (SpaceToBatchND, index:51): [[4L, 13L, 13L, 960L]]
MobilenetV2/expanded_conv_14/depthwise/Relu6 (DepthwiseConv2d, index:52): [[4L, 11L, 11L, 960L]]
MobilenetV2/expanded_conv_14/depthwise/depthwise/BatchToSpaceND (BatchToSpaceND, index:53): [[1L, 21L, 21L, 960L]]
MobilenetV2/expanded_conv_14/project/conv2d/Conv2D (Conv2D, index:54): [[1L, 21L, 21L, 160L]]
MobilenetV2/expanded_conv_14/add (Eltwise, index:55): [[1L, 21L, 21L, 160L]]
MobilenetV2/expanded_conv_15/expand/Relu6 (Conv2D, index:56): [[1L, 21L, 21L, 960L]]
MobilenetV2/expanded_conv_15/depthwise/depthwise/SpaceToBatchND (SpaceToBatchND, index:57): [[4L, 13L, 13L, 960L]]
MobilenetV2/expanded_conv_15/depthwise/Relu6 (DepthwiseConv2d, index:58): [[4L, 11L, 11L, 960L]]
MobilenetV2/expanded_conv_15/depthwise/depthwise/BatchToSpaceND (BatchToSpaceND, index:59): [[1L, 21L, 21L, 960L]]
MobilenetV2/expanded_conv_15/project/conv2d/Conv2D (Conv2D, index:60): [[1L, 21L, 21L, 160L]]
MobilenetV2/expanded_conv_15/add (Eltwise, index:61): [[1L, 21L, 21L, 160L]]
MobilenetV2/expanded_conv_16/expand/Relu6 (Conv2D, index:62): [[1L, 21L, 21L, 960L]]
MobilenetV2/expanded_conv_16/depthwise/depthwise/SpaceToBatchND (SpaceToBatchND, index:63): [[4L, 13L, 13L, 960L]]
MobilenetV2/expanded_conv_16/depthwise/Relu6 (DepthwiseConv2d, index:64): [[4L, 11L, 11L, 960L]]
MobilenetV2/expanded_conv_16/depthwise/depthwise/BatchToSpaceND (BatchToSpaceND, index:65): [[1L, 21L, 21L, 960L]]
MobilenetV2/expanded_conv_16/project/conv2d/Conv2D (Conv2D, index:66): [[1L, 21L, 21L, 320L]]
average_pooling2d/AvgPool (Pooling, index:67): [[1L, 1L, 1L, 320L]]
image_pooling/Relu (Conv2D, index:68): [[1L, 1L, 1L, 256L]]
ResizeBilinear (ResizeBilinear, index:69): [[1L, 21L, 21L, 256L]]
aspp0/Relu (Conv2D, index:70): [[1L, 21L, 21L, 256L]]
concat (Concat, index:71): [[1L, 21L, 21L, 512L]]
concat_projection/Relu (Conv2D, index:72): [[1L, 21L, 21L, 256L]]
logits/semantic/conv2d/BiasAdd (Conv2D, index:73): [[1L, 21L, 21L, 2L]]
ResizeBilinear_1 (ResizeBilinear, index:74): [[1L, 321L, 321L, 2L]]
ArgMax (ArgMax, index:75): [[1L, 321L, 321L]]
Output (ExpandDims, index:76): [[1L, 321L, 321L, 1L]]
update data format
Transpose arguments based on data format
Add default quantize info for input
Input range input_data: [-1.0, 1.0]
Add default quantize info for ops like Pooling, Softmax
Traceback (most recent call last):
  File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter.py", line 422, in <module>
    main(unused_args=[sys.argv[0]] + unparsed)
  File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter.py", line 231, in main
    output_graph_def, quantize_activation_info = mace_transformer.run()
  File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/transformer.py", line 137, in run
    changed = transformer()
  File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/transformer.py", line 1860, in add_quantize_tensor_range
    self.copy_quantize_info(op, producer_op.quantize_info[0])
  File "/root/.cache/bazel/_bazel_root/b5736f083f32f2cf769c3125e93cb921/execroot/mace/bazel-out/k8-fastbuild/bin/mace/python/tools/converter.runfiles/com_google_protobuf/python/google/protobuf/internal/containers.py", line 204, in __getitem__
    return self._values[key]
IndexError: list index out of range
Traceback (most recent call last):
  File "tools/converter.py", line 1363, in <module>
    flags.func(flags)
  File "tools/converter.py", line 866, in convert_func
    convert_model(configs, flags.cl_mem_type)
  File "tools/converter.py", line 794, in convert_model
    ",".join(model_config.get(YAMLKeyword.graph_optimize_options, [])))
  File "/home/wcf/mace-master/tools/sh_commands.py", line 553, in gen_model_code
    _fg=True)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/sh.py", line 1413, in __call__
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /root/.pyenv/versions/2.7.12/bin/python bazel-bin/mace/python/tools/converter -u --platform=tensorflow --model_file=./frozen_eval_graph.pb --weight_file= --model_checksum=77b9c13bfa5691dc78b5ed409ce1c3c2041bd7208075513bf872b9877c617d00 --weight_checksum= --input_node=input_data --input_data_types=float32 --input_data_formats=NHWC --output_node=Output --output_data_types=float32 --output_data_formats=NHWC --check_node= --runtime=cpu --template=mace/python/tools --model_tag=mobilenet_v2_quantize_retrain --input_shape=1,321,321,3 --input_range=-1.0,1.0 --output_shape=1,321,321 --check_shape= --dsp_mode=0 --embed_model_data=False --winograd=0 --quantize=1 --quantize_large_weights=0 --quantize_range_file= --change_concat_ranges=0 --obfuscate=0 --output_dir=mace/codegen/models/mobilenet_v2_quantize_retrain --model_graph_format=file --data_type=fp32_fp32 --graph_optimize_options= --cl_mem_type=image

Additional context

Add any other context about the problem here, e.g., what you have modified about the code.

wcfzl avatar Jul 26 '19 02:07 wcfzl

我从https://github.com/tensorflow/tensorflow/blob/r1.12/tensorflow/contrib/lite/g3doc/models.md 下载了Mobilenet_v2_1.0_224_quant,并用mace master转换成功。 你用的哪个模型,mace是哪个版本?

lee-bin avatar Jul 26 '19 03:07 lee-bin

我从https://github.com/tensorflow/tensorflow/blob/r1.12/tensorflow/contrib/lite/g3doc/models.md 下载了Mobilenet_v2_1.0_224_quant,并用mace master转换成功。 你用的哪个模型,mace是哪个版本? mace是latest版本,tensorflow1.14。我又试了一下,tensorflow官方的模型可以正常转换,但我自己训练的模型mobilenetv2+deeplabv3+ 无法转换(可以正常转tflite) 报错如下 library_name: mobilenet-v2-quantize-retrain target_abis: [arm64-v8a,armeabi-v7a] model_graph_format: file model_data_format: file models: mobilenet_v2_quantize_retrain: platform: tensorflow model_file_path: ./model.pb model_sha256_checksum: c90e0a6ac00ef6969723bb90d27068df2734792e4eb6c65c24a9a2ee3d693042 subgraphs: - input_tensors: - input_data input_shapes: - 1,321,321,3 input_ranges: - -1.0,1.0 output_tensors: - output_logit output_shapes: - 1,321,321,2 runtime: cpu limit_opencl_kernel_time: 0 nnlib_graph_mode: 0 obfuscate: 0 winograd: 0 quantize: 1

`Transform fake quantize Remove identity: MobilenetV2/Conv/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_1/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_1/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_1/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_2/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_2/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_2/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_2/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_3/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_3/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_3/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_4/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_4/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_4/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_4/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_5/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_5/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_5/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_5/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_6/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_6/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_6/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_7/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_7/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_7/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_7/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_8/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_8/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_8/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_8/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_9/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_9/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_9/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_9/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_10/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_10/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_10/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_11/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_11/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_11/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_11/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_12/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_12/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_12/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_12/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_13/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_13/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_13/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_14/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_14/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_14/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_14/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_15/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_15/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_15/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_15/add/activation_Add_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_16/expand/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_16/depthwise/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: MobilenetV2/expanded_conv_16/project/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: aspp0/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: image_pooling/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: concat_projection/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: logits/semantic/conv2d/act_quant/FakeQuantWithMinMaxVars(Identity) Remove identity: output_logit(Identity) Fold biasadd: logits/semantic/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/Conv/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_1/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_1/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_2/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_2/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_3/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_3/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_4/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_4/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_5/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_5/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_6/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_6/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_7/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_7/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_8/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_8/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_9/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_9/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_10/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_10/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_11/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_11/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_12/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_12/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_13/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_13/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_14/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_14/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_15/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_15/depthwise/depthwise(DepthwiseConv2d) Fold activation: MobilenetV2/expanded_conv_16/expand/conv2d/Conv2D(Conv2D) Fold activation: MobilenetV2/expanded_conv_16/depthwise/depthwise(DepthwiseConv2d) Fold activation: aspp0/conv2d/Conv2D(Conv2D) Fold activation: image_pooling/conv2d/Conv2D(Conv2D) Fold activation: concat_projection/conv2d/Conv2D(Conv2D) Transpose filters to OHWI Add OpenCL informations Sort by execution Final ops: MobilenetV2/Conv/Relu6 (Conv2D, index:0): [[1L, 161L, 161L, 32L]] MobilenetV2/expanded_conv/depthwise/Relu6 (DepthwiseConv2d, index:1): [[1L, 161L, 161L, 32L]] MobilenetV2/expanded_conv/project/conv2d/Conv2D (Conv2D, index:2): [[1L, 161L, 161L, 16L]] MobilenetV2/expanded_conv_1/expand/Relu6 (Conv2D, index:3): [[1L, 161L, 161L, 96L]] MobilenetV2/expanded_conv_1/depthwise/Relu6 (DepthwiseConv2d, index:4): [[1L, 81L, 81L, 96L]] MobilenetV2/expanded_conv_1/project/conv2d/Conv2D (Conv2D, index:5): [[1L, 81L, 81L, 24L]] MobilenetV2/expanded_conv_2/expand/Relu6 (Conv2D, index:6): [[1L, 81L, 81L, 144L]] MobilenetV2/expanded_conv_2/depthwise/Relu6 (DepthwiseConv2d, index:7): [[1L, 81L, 81L, 144L]] MobilenetV2/expanded_conv_2/project/conv2d/Conv2D (Conv2D, index:8): [[1L, 81L, 81L, 24L]] MobilenetV2/expanded_conv_2/add (Eltwise, index:9): [[1L, 81L, 81L, 24L]] MobilenetV2/expanded_conv_3/expand/Relu6 (Conv2D, index:10): [[1L, 81L, 81L, 144L]] MobilenetV2/expanded_conv_3/depthwise/Relu6 (DepthwiseConv2d, index:11): [[1L, 41L, 41L, 144L]] MobilenetV2/expanded_conv_3/project/conv2d/Conv2D (Conv2D, index:12): [[1L, 41L, 41L, 32L]] MobilenetV2/expanded_conv_4/expand/Relu6 (Conv2D, index:13): [[1L, 41L, 41L, 192L]] MobilenetV2/expanded_conv_4/depthwise/Relu6 (DepthwiseConv2d, index:14): [[1L, 41L, 41L, 192L]] MobilenetV2/expanded_conv_4/project/conv2d/Conv2D (Conv2D, index:15): [[1L, 41L, 41L, 32L]] MobilenetV2/expanded_conv_4/add (Eltwise, index:16): [[1L, 41L, 41L, 32L]] MobilenetV2/expanded_conv_5/expand/Relu6 (Conv2D, index:17): [[1L, 41L, 41L, 192L]] MobilenetV2/expanded_conv_5/depthwise/Relu6 (DepthwiseConv2d, index:18): [[1L, 41L, 41L, 192L]] MobilenetV2/expanded_conv_5/project/conv2d/Conv2D (Conv2D, index:19): [[1L, 41L, 41L, 32L]] MobilenetV2/expanded_conv_5/add (Eltwise, index:20): [[1L, 41L, 41L, 32L]] MobilenetV2/expanded_conv_6/expand/Relu6 (Conv2D, index:21): [[1L, 41L, 41L, 192L]] MobilenetV2/expanded_conv_6/depthwise/Relu6 (DepthwiseConv2d, index:22): [[1L, 21L, 21L, 192L]] MobilenetV2/expanded_conv_6/project/conv2d/Conv2D (Conv2D, index:23): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_7/expand/Relu6 (Conv2D, index:24): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_7/depthwise/Relu6 (DepthwiseConv2d, index:25): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_7/project/conv2d/Conv2D (Conv2D, index:26): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_7/add (Eltwise, index:27): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_8/expand/Relu6 (Conv2D, index:28): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_8/depthwise/Relu6 (DepthwiseConv2d, index:29): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_8/project/conv2d/Conv2D (Conv2D, index:30): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_8/add (Eltwise, index:31): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_9/expand/Relu6 (Conv2D, index:32): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_9/depthwise/Relu6 (DepthwiseConv2d, index:33): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_9/project/conv2d/Conv2D (Conv2D, index:34): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_9/add (Eltwise, index:35): [[1L, 21L, 21L, 64L]] MobilenetV2/expanded_conv_10/expand/Relu6 (Conv2D, index:36): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_10/depthwise/Relu6 (DepthwiseConv2d, index:37): [[1L, 21L, 21L, 384L]] MobilenetV2/expanded_conv_10/project/conv2d/Conv2D (Conv2D, index:38): [[1L, 21L, 21L, 96L]] MobilenetV2/expanded_conv_11/expand/Relu6 (Conv2D, index:39): [[1L, 21L, 21L, 576L]] MobilenetV2/expanded_conv_11/depthwise/Relu6 (DepthwiseConv2d, index:40): [[1L, 21L, 21L, 576L]] MobilenetV2/expanded_conv_11/project/conv2d/Conv2D (Conv2D, index:41): [[1L, 21L, 21L, 96L]] MobilenetV2/expanded_conv_11/add (Eltwise, index:42): [[1L, 21L, 21L, 96L]] MobilenetV2/expanded_conv_12/expand/Relu6 (Conv2D, index:43): [[1L, 21L, 21L, 576L]] MobilenetV2/expanded_conv_12/depthwise/Relu6 (DepthwiseConv2d, index:44): [[1L, 21L, 21L, 576L]] MobilenetV2/expanded_conv_12/project/conv2d/Conv2D (Conv2D, index:45): [[1L, 21L, 21L, 96L]] MobilenetV2/expanded_conv_12/add (Eltwise, index:46): [[1L, 21L, 21L, 96L]] MobilenetV2/expanded_conv_13/expand/Relu6 (Conv2D, index:47): [[1L, 21L, 21L, 576L]] MobilenetV2/expanded_conv_13/depthwise/Relu6 (DepthwiseConv2d, index:48): [[1L, 21L, 21L, 576L]] MobilenetV2/expanded_conv_13/project/conv2d/Conv2D (Conv2D, index:49): [[1L, 21L, 21L, 160L]] MobilenetV2/expanded_conv_14/expand/Relu6 (Conv2D, index:50): [[1L, 21L, 21L, 960L]] MobilenetV2/expanded_conv_14/depthwise/Relu6 (DepthwiseConv2d, index:51): [[1L, 21L, 21L, 960L]] MobilenetV2/expanded_conv_14/project/conv2d/Conv2D (Conv2D, index:52): [[1L, 21L, 21L, 160L]] MobilenetV2/expanded_conv_14/add (Eltwise, index:53): [[1L, 21L, 21L, 160L]] MobilenetV2/expanded_conv_15/expand/Relu6 (Conv2D, index:54): [[1L, 21L, 21L, 960L]] MobilenetV2/expanded_conv_15/depthwise/Relu6 (DepthwiseConv2d, index:55): [[1L, 21L, 21L, 960L]] MobilenetV2/expanded_conv_15/project/conv2d/Conv2D (Conv2D, index:56): [[1L, 21L, 21L, 160L]] MobilenetV2/expanded_conv_15/add (Eltwise, index:57): [[1L, 21L, 21L, 160L]] MobilenetV2/expanded_conv_16/expand/Relu6 (Conv2D, index:58): [[1L, 21L, 21L, 960L]] MobilenetV2/expanded_conv_16/depthwise/Relu6 (DepthwiseConv2d, index:59): [[1L, 21L, 21L, 960L]] MobilenetV2/expanded_conv_16/project/conv2d/Conv2D (Conv2D, index:60): [[1L, 21L, 21L, 320L]] average_pooling2d/AvgPool (Pooling, index:61): [[1L, 1L, 1L, 320L]] image_pooling/Relu (Conv2D, index:62): [[1L, 1L, 1L, 256L]] ResizeBilinear (ResizeBilinear, index:63): [[1L, 21L, 21L, 256L]] aspp0/Relu (Conv2D, index:64): [[1L, 21L, 21L, 256L]] concat (Concat, index:65): [[1L, 21L, 21L, 512L]] concat_projection/Relu (Conv2D, index:66): [[1L, 21L, 21L, 256L]] logits/semantic/conv2d/BiasAdd (Conv2D, index:67): [[1L, 21L, 21L, 2L]] ResizeBilinear_1 (ResizeBilinear, index:68): [[1L, 321L, 321L, 2L]] update data format Transpose arguments based on data format Add default quantize info for input Input range input_data: [-1.0, 1.0] Add default quantize info for ops like Pooling, Softmax Add mace quantize and dequantize nodes Quantize weights Traceback (most recent call last): File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter.py", line 422, in main(unused_args=[sys.argv[0]] + unparsed) File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter.py", line 231, in main output_graph_def, quantize_activation_info = mace_transformer.run() File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/transformer.py", line 137, in run changed = transformer() File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/transformer.py", line 1661, in quantize_weights self.quantize_tensor(tensor) File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/converter_tool/transformer.py", line 1643, in quantize_tensor non_zero) File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/quantization/quantize_util.py", line 143, in quantize output = np.clip((np.round(zero + data / scale).astype(np.int32)), 0, 255) TypeError: unsupported operand type(s) for /: 'RepeatedScalarFieldContainer' and 'float' Traceback (most recent call last): File "tools/converter.py", line 1363, in flags.func(flags) File "tools/converter.py", line 866, in convert_func convert_model(configs, flags.cl_mem_type) File "tools/converter.py", line 794, in convert_model ",".join(model_config.get(YAMLKeyword.graph_optimize_options, []))) File "/home/wcf/mace-master/tools/sh_commands.py", line 553, in gen_model_code _fg=True) File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/sh.py", line 1413, in call raise exc sh.ErrorReturnCode_1:

RAN: /root/.pyenv/versions/2.7.12/bin/python bazel-bin/mace/python/tools/converter -u --platform=tensorflow --model_file=./model.pb --weight_file= --model_checksum=c90e0a6ac00ef6969723bb90d27068df2734792e4eb6c65c24a9a2ee3d693042 --weight_checksum= --input_node=input_data --input_data_types=float32 --input_data_formats=NHWC --output_node=output_logit --output_data_types=float32 --output_data_formats=NHWC --check_node= --runtime=cpu --template=mace/python/tools --model_tag=mobilenet_v2_quantize_retrain --input_shape=1,321,321,3 --input_range=-1.0,1.0 --output_shape=1,321,321,2 --check_shape= --dsp_mode=0 --embed_model_data=False --winograd=0 --quantize=1 --quantize_large_weights=0 --quantize_range_file= --change_concat_ranges=0 --obfuscate=0 --output_dir=mace/codegen/models/mobilenet_v2_quantize_retrain --model_graph_format=file --data_type=fp32_fp32 --graph_optimize_options= --cl_mem_type=image`

wcfzl avatar Jul 26 '19 05:07 wcfzl

@lee-bin 我打印了出错的地方 File "/home/wcf/mace-master/bazel-bin/mace/python/tools/converter.runfiles/mace/mace/python/tools/quantization/quantize_util.py", line 143, in quantize output = np.clip((np.round(zero + data / scale).astype(np.int32)), 0, 255) 发现data scale 都是全0,似乎是没有读到相应的值

wcfzl avatar Jul 26 '19 06:07 wcfzl

可以提供一个能复现该问题的模型吗

lee-bin avatar Jul 26 '19 06:07 lee-bin

可以提供一个能复现该问题的模型吗

https://github.com/wcfzl/deeplab-mobilenetv2-Quantization-aware-training-model

wcfzl avatar Jul 26 '19 06:07 wcfzl

看起来是Tensorflow transform_graph的问题,这行之后权重变为0https://github.com/XiaoMi/mace/blob/master/mace/python/tools/converter_tool/tensorflow_converter.py#L292

lee-bin avatar Jul 26 '19 08:07 lee-bin

Having the same issue here with another TF model

gasgallo avatar Oct 31 '19 07:10 gasgallo