Open eric-haibin-lin opened 5 years ago
Hey, this is the MXNet Label Bot. Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it. Here are my recommended label(s): Bug
There is also no documentation for example inputs/outputs.
Is the problem here that the length is fp32 and not one of integer types?
@eric-haibin-lin This is what I got on my end with your code
>>> import mxnet as mx
>>> len = mx.nd.array([1,2]);
>>> x = mx.nd.array([[1,2],[3,4]])
>>> mx.nd.softmax(data=x, length=len, use_length=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 234, in __repr__
return '\n%s\n<%s %s @%s>' % (str(self.asnumpy()),
File "/home/ubuntu/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 2504, in asnumpy
ctypes.c_size_t(data.size)))
File "/home/ubuntu/incubator-mxnet/python/mxnet/base.py", line 254, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [05:19:12] src/operator/nn/./softmax-inl.h:825: This operation only support integer types, not float32
If I change your code to:
import mxnet as mx
len = mx.nd.array([1,2], dtype='int32');
x = mx.nd.array([[1,2],[3,4]]);
mx.nd.softmax(data=x, length=len, use_length=True)
I get:
[[1. 0. ]
[0.26894143 0.7310586 ]]
<NDArray 2x2 @cpu(0)>
Which seems like a correct answer to me.
@haojin2 thanks. I'm not sure why it does not show the intended error msg on my. I was using Mac. Were you also using macOs? Also - in the doc shall we include an example of using use_len=True, and that the length must be int types?
MXNet version:
Sample code:
Error message:
@haojin2