Closed y-lu closed 6 years ago
@y-lu thanks for the issue, I was able to reproduce, we will take a look.
In general, we should not pass mxnet nd arrays into Keras operator. mxnet nd arrays is only used in the backend and hidden from user. Please use numpy arrays as inputs.
a = np.ones(3)
K.equal(a, a).shape
>>>(3,)
Closing this issue. @y-lu please feel free to re-open if you have any other questions.
Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.
Thank you!
[X] Check that you are up-to-date with the master branch of Keras. You can update with: pip install git+git://github.com/awslabs/keras-apache-mxnet.git --upgrade --no-deps
[X] If running on MXNet, check that you are up-to-date with the latest version. The installation instructions can be found here
[ ] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
[ ] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with: pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
[ ] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
Here's how to reproduce the problem:
import mxnet as mx, keras.backend as K
a = mx.nd.ones(3)
a.shape # return (3,) as expected mx.nd.equal(a,a).shape # return (3,) as expected
K.equal(a,a).shape # returns (3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), which is wrong
The same problem happens with other comparison operators (greater, etc.)