MMdnn: MXNet convertorToIR don't parse 'attrs' layer parameters
Platform: Ununtu 16.04
Python version: 3.6
Source framework with version: MXNet 1.0.0 with GPU
Destination framework with version: TensorFlow 1.4.1 with GPU
Pre-trained model path: LResNet50E-IR
Model json-file contain layers in the following form:
{ "op": "Convolution", "name": "conv0", "attrs": { "kernel": "(3, 3)", "no_bias": "True", "num_filter": "64", "pad": "(1, 1)", "stride": "(1, 1)", "workspace": "256" }, "inputs": [[3, 0, 0], [4, 0, 0]] }
Running scripts:
python -m mmdnn.conversion._script.convertToIR -f mxnet -n model-symbol.json -w model-0000.params -d model-descr512 --inputShape 3 112 112
Error:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/opt/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 140, in <module>
_main()
File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 135, in _main
ret = _convert(args)
File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 72, in _convert
parser.run(args.dstPath)
File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/common/DataStructure/parser.py", line 22, in run
self.gen_IR()
File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 266, in gen_IR
func(current_node)
File "/opt/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/mxnet/mxnet_parser.py", line 457, in rename_Convolution
assert "attr" in source_node.layer or "param" in source_node.layer
AssertionError
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 43 (17 by maintainers)
Commits related to this issue
- modifed to issue #85 — committed to microsoft/MMdnn by JiahaoYao 6 years ago
- Merge pull request #179 from Microsoft/v-ruzha modifed to issue #85 — committed to microsoft/MMdnn by kitstar 6 years ago
Hi @StanislasBertrand , Please refer to this issue
To sum up, I have compared the inference results of converted tensorflow and original mxnet. They are exactly the same. The details go as follows: First, as @belgraviton said,
Here comes the IR structure.
Secondly, just as @xsr-ai mentioned,
Here comes the tensorflow snippet.
However, Two things have to be modified in this snippet.
_mulscalar0_secondand_minusscalar0_secondshould be changed, saymulscalar0_secondandminusscalar0_secondrespectively.Then the code should be like
In my view, this may because the node name can not begin with ‘_’ in tensorflow.
The code (line 255-260) should be converted from
to
In my opinion, this is because in this mxnet json, there is no flatten operator before the fc layer. That is why there is no flatten layer when converted to tensorflow. Here, we add this flatten layer to the tensorflow code.
As to the Sanity checks, I compare the inference result of the two. You might take it as a reference. For mxnet,
For tensorflow,
Exploit the script
tensorflow_inference.pyone can get the inference by running
To sum up, the two results are exactly the same,