microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.8k stars 965 forks source link

Warning: MXNet Parser has not supported operator SoftmaxActivation with name cls_prob. #141

Closed IamJasonYe closed 6 years ago

IamJasonYe commented 6 years ago

Platform (like ubuntu 16.04/win10): Ubuntu 16.04

Python version: 2.7.12

Source framework with version (like Tensorflow 1.4.1 with GPU): mxnet 1.1.0 with cu80 GPU

Destination framework with version (like CNTK 2.3 with GPU): IR

Pre-trained model path (webpath or webdisk path): N/A

Running scripts: python -m mmdnn.conversion._script.convertToIR -f mxnet -n mynet-symbol.json -w mynet.params -d ir/mynet --inputShape 3 12 12

/home/jason/.virtualenvs/caffe-mxnet-cuda8/local/lib/python2.7/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters /home/jason/.virtualenvs/caffe-mxnet-cuda8/local/lib/python2.7/site-packages/mxnet/module/base_module.py:53: UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of: data warnings.warn(msg) Warning: MXNet Parser has not supported operator null with name data. Warning: convert the null operator with name [data] into input layer. Warning: MXNet Parser has not supported operator SoftmaxActivation with name cls_prob. IR network structure is saved as [../ir/pnet.json]. IR network structure is saved as [../ir/pnet.pb]. IR weights are saved as [../ir/pnet.npy].

And here is my symbol.json of mxnet model

{ "nodes": [ { "op": "null", "name": "data", "inputs": [] }, { "op": "null", "name": "conv1_weight", "attrs": { "kernel": "(3, 3)", "num_filter": "10" }, "inputs": [] }, { "op": "null", "name": "conv1_bias", "attrs": { "kernel": "(3, 3)", "num_filter": "10" }, "inputs": [] }, { "op": "Convolution", "name": "conv1", "attrs": { "kernel": "(3, 3)", "num_filter": "10" }, "inputs": [[0, 0, 0], [1, 0, 0], [2, 0, 0]] }, { "op": "null", "name": "prelu1_gamma", "attrs": { "init": "[\"Constant\", {\"value\": 0.25}]", "act_type": "prelu" }, "inputs": [] }, { "op": "LeakyReLU", "name": "prelu1", "attrs": {"act_type": "prelu"}, "inputs": [[3, 0, 0], [4, 0, 0]] }, { "op": "Pooling", "name": "pool1", "attrs": { "kernel": "(2, 2)", "pool_type": "max", "pooling_convention": "full", "stride": "(2, 2)" }, "inputs": [[5, 0, 0]] }, { "op": "null", "name": "conv2_weight", "attrs": { "kernel": "(3, 3)", "num_filter": "16" }, "inputs": [] }, { "op": "null", "name": "conv2_bias", "attrs": { "kernel": "(3, 3)", "num_filter": "16" }, "inputs": [] }, { "op": "Convolution", "name": "conv2", "attrs": { "kernel": "(3, 3)", "num_filter": "16" }, "inputs": [[6, 0, 0], [7, 0, 0], [8, 0, 0]] }, { "op": "null", "name": "prelu2_gamma", "attrs": { "init": "[\"Constant\", {\"value\": 0.25}]", "act_type": "prelu" }, "inputs": [] }, { "op": "LeakyReLU", "name": "prelu2", "attrs": {"act_type": "prelu"}, "inputs": [[9, 0, 0], [10, 0, 0]] }, { "op": "null", "name": "conv3_weight", "attrs": { "kernel": "(3, 3)", "num_filter": "32" }, "inputs": [] }, { "op": "null", "name": "conv3_bias", "attrs": { "kernel": "(3, 3)", "num_filter": "32" }, "inputs": [] }, { "op": "Convolution", "name": "conv3", "attrs": { "kernel": "(3, 3)", "num_filter": "32" }, "inputs": [[11, 0, 0], [12, 0, 0], [13, 0, 0]] }, { "op": "null", "name": "prelu3_gamma", "attrs": { "init": "[\"Constant\", {\"value\": 0.25}]", "act_type": "prelu" }, "inputs": [] }, { "op": "LeakyReLU", "name": "prelu3", "attrs": {"act_type": "prelu"}, "inputs": [[14, 0, 0], [15, 0, 0]] }, { "op": "null", "name": "conv4_1_weight", "attrs": { "kernel": "(1, 1)", "num_filter": "2" }, "inputs": [] }, { "op": "null", "name": "conv4_1_bias", "attrs": { "kernel": "(1, 1)", "num_filter": "2" }, "inputs": [] }, { "op": "Convolution", "name": "conv4_1", "attrs": { "kernel": "(1, 1)", "num_filter": "2" }, "inputs": [[16, 0, 0], [17, 0, 0], [18, 0, 0]] }, { "op": "SoftmaxActivation", "name": "cls_prob", "attrs": {"mode": "channel"}, "inputs": [[19, 0, 0]] }, { "op": "null", "name": "conv4_2_weight", "attrs": { "kernel": "(1, 1)", "num_filter": "4" }, "inputs": [] }, { "op": "null", "name": "conv4_2_bias", "attrs": { "kernel": "(1, 1)", "num_filter": "4" }, "inputs": [] }, { "op": "Convolution", "name": "conv4_2", "attrs": { "kernel": "(1, 1)", "num_filter": "4" }, "inputs": [[16, 0, 0], [21, 0, 0], [22, 0, 0]] } ], "arg_nodes": [ 0, 1, 2, 4, 7, 8, 10, 12, 13, 15, 17, 18, 21, 22 ], "node_row_ptr": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ], "heads": [[20, 0, 0], [23, 0, 0]], "attrs": {"mxnet_version": ["int", 10100]} }%

kitstar commented 6 years ago

Hi @IamJasonYe , it is just a warning which can be ignored. Thanks.

IamJasonYe commented 6 years ago

Thx @kitstar .

[Solved]

Actually I found SoftmaxActivation opeartor is not a supportive type in the mxnet parser right now. So I changed it into the SoftmaxOutput and with parameter multi_output": "1".

ref by Joey in Zhihu

lygstate commented 6 years ago

My network have such an error

[01:22:00] C:\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_json_util.cc:209: Loading symbol saved by previous version v0.9.5. Attempting to upgrade...
[01:22:01] C:\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_json_util.cc:217: Symbol successfully upgraded!
e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mxnet\module\base_module.py:54: UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of:
        data
  warnings.warn(msg)
Warning: MXNet Parser has not supported operator null with name data.
Warning: convert the null operator with name [data] into input layer.
[0, 0, 62, 36]
{'op': 'Activation', 'name': 'hres4_relu', 'attr': {'act_type': 'relu'}, 'inputs': [[188, 0, 0]]}
{'act_type': 'relu'}
[0, 0, 122, 70]
{'op': 'Activation', 'name': 'hres3_relu', 'attr': {'act_type': 'relu'}, 'inputs': [[132, 0, 0]]}
{'act_type': 'relu'}
[0, 0, 121, 68]
{'op': 'Activation', 'name': 'hres3_frelu', 'attr': {'act_type': 'relu'}, 'inputs': [[263, 0, 0]]}
{'act_type': 'relu'}
Warning: SoftmaxOutput attrs are not supported in IR.
infer_shape error. Arguments:
  data: (1, 3, 960, 540)
Traceback (most recent call last):
  File "c:\users\lygstate\appdata\local\programs\python\python36\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\lygstate\appdata\local\programs\python\python36\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "E:\CI-Cor-Ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\Scripts\mmconvert.exe\__main__.py", line 9, in <module>
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mmdnn\conversion\_script\convert.py", line 102, in _main
    ret = convertToIR._convert(ir_args)
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mmdnn\conversion\_script\convertToIR.py", line 115, in _convert
    parser.run(args.dstPath)
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mmdnn\conversion\common\DataStructure\parser.py", line 22, in run
    self.gen_IR()
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 265, in gen_IR
    func(current_node)
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 629, in rename_SoftmaxOutput
    self.set_output_shape(source_node, IR_node)
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 284, in set_output_shape
    arg_shape, output_shape, aux_shape = sym.infer_shape(data = self.data_shape)
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mxnet\symbol\symbol.py", line 990, in infer_shape
    res = self._infer_shape_impl(False, *args, **kwargs)
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mxnet\symbol\symbol.py", line 1120, in _infer_shape_impl
    ctypes.byref(complete)))
  File "e:\ci-cor-ready\ai\face-io\face-detection\mx2tensorflow-js\tensorflow_env\lib\site-packages\mxnet\base.py", line 149, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: Error in operator cls_prob_l2_: [01:22:09] C:\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_op_util.cc:194: Check failed: prop.inputs.size() == iattr->size() (2 vs. 1) op=SoftmaxOutput, inputs.size=2, iattr.size=1, arg.size=2

What's happening?