开发环境:
MegEngine 1.0.0
Python 3.7
Jupyter Notebook
按照https://www.bilibili.com/video/BV1Zf4y1Q7aZ?p=2中第六讲进行部署进阶:推理端优化时,执行到QAT量化第四步:将模型转换为量化模型,并执行 Dump 用于后续模型部署时报错。执行代码如下:
!python3 inference.py -a shufflenet_v2_x0_5 --checkpoint /home/megstudio/workspace/megengine_quantize_test/Models/official/quantization/result/model/shufflenet_v2_x0_5.qat/checkpoint-final.pkl --mode quantized --dump
报错信息如下:
Traceback (most recent call last):
File "inference.py", line 111, in <module>
main()
File "inference.py", line 87, in main
probs = infer_func(processed_img)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/jit/tracing.py", line 507, in __call__
outputs = self.__wrapped__(*args, **kwargs)
File "inference.py", line 79, in infer_func
logits = model(processed_img)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/module.py", line 103, in __call__
outputs = self.forward(*inputs, **kwargs)
File "/home/megstudio/workspace/megengine_quantize_test/Models/official/quantization/models/shufflenet_v2.py", line 192, in forward
x = self.features(x)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/module.py", line 103, in __call__
outputs = self.forward(*inputs, **kwargs)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/sequential.py", line 97, in forward
inp = layer(inp)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/module.py", line 103, in __call__
outputs = self.forward(*inputs, **kwargs)
File "/home/megstudio/workspace/megengine_quantize_test/Models/official/quantization/models/shufflenet_v2.py", line 108, in forward
return self.concat((self.branch_proj(x_proj), self.branch_main(x)), 1)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/quantized/module.py", line 23, in __call__
return super().__call__(*inputs, **kwargs)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/module.py", line 103, in __call__
outputs = self.forward(*inputs, **kwargs)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/module/quantized/concat.py", line 27, in forward
return F.concat(new_inps, axis)
File "/home/megstudio/.miniconda/envs/xuan/lib/python3.7/site-packages/megengine/functional/tensor.py", line 260, in concat
if len(inps) == 1:
TypeError: object of type 'generator' has no len()