cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
asobeih
Explorer
Explorer
296 Views
Registered: ‎02-13-2016

Vitis AI Quantizer Error

Hello,

I am trying to quantize my own CNN model. I generated the frozen graph successfully (or that's what I hope). This is what I get when I inspect my frozen graph:

Op types used: 57 Const, 28 Identity, 24 Switch, 8 FusedBatchNorm, 4 Merge, 3 Conv2D, 2 MatMul, 2 BiasAdd, 2 Relu6, 1 Mean, 1 Softmax, 1 Relu, 1 PlaceholderWithDefault, 1 Placeholder, 1 Pad, 1 DepthwiseConv2dNative, 1 ConcatV2

Found 1 possible inputs: (name=input_1, type=float(1), shape=[?,512,512,1]) 
Found 1 possible outputs: (name=predictions/Softmax, op=Softmax) 

When I run the quantizer, I get the following error:

processing images: ./itip/data/calib/solar/Batch2_0.jpg

processing images: ./itip/data/calib/nonsolar/Batch1_1.jpg

processing images: ./itip/data/calib/solar/Batch_0.jpg

processing images: ./itip/data/calib/nonsolar/Batch_0.jpg

input shape of iter 0 is (4, 512, 512, 1)

INFO: Float Graph Check Done.
The input dim: 1 dim size: 16 expected width: 0
Traceback (most recent call last):
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/bin/vai_q_tensorflow", line 11, in <module>
    sys.exit(run_main())
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 781, in run_main
    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 780, in <lambda>
    my_main = lambda unused_args: main(unused_args, FLAGS)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 576, in main
    flags.skip_check)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 326, in quantize_frozen
    q_config, s_config)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/decent_q.py", line 256, in calibrate_frozen
    calib_graph_def = CreateQuantizeCalibrationGraphDef(input_graph_def, q_config)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/contrib/decent_q/python/quantize_graph.py", line 172, in CreateQuantizeCalibrationGraphDef
    input_graph_def_string, config.to_string(), status)
  File "/opt/vitis_ai/conda/envs/vitis-ai-tensorflow/lib/python3.6/site-packages/tensorflow_core/python/framework/errors_impl.py", line 556, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Beta input to batch norm has bad shape: [16]

How to solve this problem? Not sure if this is useful or not, but in my CNN model, the first BatchNorm layer has an input shape of (?,256,256,16) and the output shape is (?,256,256,16).

Thanks.

0 Kudos
1 Reply
jasonwu
Moderator
Moderator
278 Views
Registered: ‎03-27-2013

Point to the topic with similar issue created by same account, we can discuss the issue there:

https://forums.xilinx.com/t5/AI-and-Vitis-AI/Error-While-Quantizing-my-Own-CNN-Frozen-Model/td-p/1150057

Please feel free to comment if it is not about the same question.

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------
0 Kudos