Onnx: [Solved]SoftmaxActivation isn't supported by ONNX - workaround

Created on 6 May 2019  路  3Comments  路  Source: onnx/onnx

Hi,
I鈥檝e a pretrained model that uses SoftmaxActivation operation to give probability estimations of how close the current output to the desired output.

When exporting this pretrained model to ONNX, it throws out an error that SoftmaxActivation op isn鈥檛 supported by ONNX (Using 1.2.2, also tried on other versions - 1.2.3, 1.3,1.4,1.5)

My question is, how can I work around this?
Note: I鈥檓 using Symbol API
Note2: My goal is to Import from ONNX to Tensorflow

Possible workaround 1:
I thought about using mx.sym.SoftmaxOutput + mx.sym.Activation to achieve the same result of SoftmaxActivation, would that work? (I鈥檒l try to do that on a dummy network until I receive an answer, also update here with any new results)

Possible workaround 2:
Also I thought, using some other layer now like Dropout layer instead (it exports to ONNX successfully), then import it to Tensorflow framework, and there change it from the Dropout to Softmax Activation. (Need to check if it鈥檚 possible)

Most helpful comment

@luan1412167
you want to use the lowercase softmax
https://mxnet.incubator.apache.org/api/python/docs/api/symbol/op/index.html?highlight=softmax#mxnet.symbol.op.softmax
not the uppercase Softmax
https://mxnet.incubator.apache.org/api/python/docs/api/symbol/op/index.html?highlight=softmax#mxnet.symbol.op.Softmax

{
      "op": "softmax", 
      "name": "xxxxxxx", 
      "attrs": {"axis": "1"}, 
      "inputs": [[xxx, 0, 0]]
 }, 

All 3 comments

used softmax with axis=1

@AnaRhisT94 here is my setup for softmax. are my setup right ?
"op": "Softmax", "name": "face_rpn_cls_prob_stride32", "attrs": {"multi_output":"true"}, "inputs": [[562, 0, 0]]

Because i got error Error in operator face_rpn_cls_prob_stride32: [17:00:41] src/operator/softmax_output.cc:86: Check failed: in_shape->size() == 2U (1 vs. 2) : Input:[data, label]

@luan1412167
you want to use the lowercase softmax
https://mxnet.incubator.apache.org/api/python/docs/api/symbol/op/index.html?highlight=softmax#mxnet.symbol.op.softmax
not the uppercase Softmax
https://mxnet.incubator.apache.org/api/python/docs/api/symbol/op/index.html?highlight=softmax#mxnet.symbol.op.Softmax

{
      "op": "softmax", 
      "name": "xxxxxxx", 
      "attrs": {"axis": "1"}, 
      "inputs": [[xxx, 0, 0]]
 }, 
Was this page helpful?
0 / 5 - 0 ratings