Error in run softmax_cross_entropy function


#1

I just run following code.

import mxnet as mx

a = mx.symbol.Variable('data')
b = mx.symbol.SoftmaxOutput(a)
label = mx.symbol.Variable('label')
e = mx.symbol.softmax_cross_entropy(b, label)

than I get:

  File "main.py", line 6, in <module>
    e = mx.symbol.softmax_cross_entropy(b, label)
  File "<string>", line 69, in softmax_cross_entropy
  File "/data00/home/zhangyonghui.98k/.anaconda2/lib/python2.7/site-packages/mxnet/_ctypes/symbol.py", line 135, in _symbol_creator
    s._compose(name=name, **kwargs)
  File "/data00/home/zhangyonghui.98k/.anaconda2/lib/python2.7/site-packages/mxnet/symbol/symbol.py", line 476, in _compose
    self.handle, name, num_args, keys, args))
  File "/data00/home/zhangyonghui.98k/.anaconda2/lib/python2.7/site-packages/mxnet/base.py", line 149, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [14:27:33] src/core/symbolic.cc:301: Not enough argument to call operator softmax_cross_entropy

What’s wrong with it?


#2

I can confirm that it is still happening.
The bug is tracked here:

Alternatively you can either use the mx.symbol.SoftmaxOutput, that use the Cross entropy loss on the backward pass to compute the gradient, if you are simply interested in training using the cross entropy loss function.

Alternatively you can compute it yourself using symbols, in a usual single label classification task, this is equivalent to the -log(proba_predicted_for_true_label)

Alternatively you can use Gluon instead that has a mx.gluon.loss.SoftmaxCrossEntropyLoss