Error in run softmax_cross_entropy function


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 "", 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/", line 135, in _symbol_creator
    s._compose(name=name, **kwargs)
  File "/data00/home/zhangyonghui.98k/.anaconda2/lib/python2.7/site-packages/mxnet/symbol/", line 476, in _compose
    self.handle, name, num_args, keys, args))
  File "/data00/home/zhangyonghui.98k/.anaconda2/lib/python2.7/site-packages/mxnet/", line 149, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [14:27:33] src/core/ Not enough argument to call operator softmax_cross_entropy

What’s wrong with it?


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