FCInter opened a new issue #9693: mx.nd.array.reshape report error when reshape with special
value -2
URL: https://github.com/apache/incubator-mxnet/issues/9693
## Description
I'm trying to reshape an ndarray from shape (2,3) to (1,2,3). I tried the command
`a.reshape((-4,1,2,-2))`
But I met with errors.
## Environment info (Required)
----------Python Info----------
('Version :', '2.7.14')
('Compiler :', 'GCC 7.2.0')
('Build :', ('default', 'Oct 16 2017 17:29:19'))
('Arch :', ('64bit', ''))
------------Pip Info-----------
('Version :', '9.0.1')
('Directory :', '/home/users/mypath/anaconda2/lib/python2.7/site-packages/pip')
----------MXNet Info-----------
/home/users/mypath/anaconda2/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py:46:
DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead
import OpenSSL.SSL
('Version :', '1.0.0')
('Directory :', '/home/users/mypath/.local/lib/python2.7/site-packages/mxnet')
----------System Info----------
('Platform :', 'Linux-3.10.0-693.2.2.el7.x86_64-x86_64-with-centos-7.4.1708-Core')
('system :', 'Linux')
----------Hardware Info----------
('machine :', 'x86_64')
('processor :', 'x86_64')
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Package used (Python/R/Scala/Julia):
Python
Installed by pip
## Error Message:
Check failed: shape_.Size() >= shape.Size() (6 vs. 16) NDArray.Reshape: target shape
size is larger current shape
Stack trace returned 10 entries:
[bt] (0) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x28965c)
[0x7f3b0cc1c65c]
[bt] (1) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2604a3e)
[0x7f3b0ef97a3e]
[bt] (2) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x260ffd2)
[0x7f3b0efa2fd2]
[bt] (3) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(MXNDArrayReshape+0x8c6)
[0x7f3b0ed760b6]
[bt] (4) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c)
[0x7f3b2784fec0]
[bt] (5) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call+0x22d)
[0x7f3b2784f87d]
[bt] (6) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/_ctypes.so(_ctypes_callproc+0x4d6)
[0x7f3b27a65736]
[bt] (7) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/_ctypes.so(+0x8a61) [0x7f3b27a5ba61]
[bt] (8) /home/users/mypath/anaconda2/bin/../lib/libpython2.7.so.1.0(PyObject_Call+0x43)
[0x7f3b2f75f773]
[bt] (9) /home/users/mypath/anaconda2/bin/../lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x190b)
[0x7f3b2f7f353b]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/users/mypath/.local/lib/python2.7/site-packages/mxnet/ndarray/ndarray.py",
line 977, in reshape
ctypes.byref(handle)))
File "/home/users/mypath/.local/lib/python2.7/site-packages/mxnet/base.py", line 146,
in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [11:40:18] src/ndarray/ndarray.cc:73: Check failed: shape_.Size()
>= shape.Size() (6 vs. 16) NDArray.Reshape: target shape size is larger current shape
Stack trace returned 10 entries:
[bt] (0) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x28965c)
[0x7f3b0cc1c65c]
[bt] (1) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2604a3e)
[0x7f3b0ef97a3e]
[bt] (2) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x260ffd2)
[0x7f3b0efa2fd2]
[bt] (3) /home/users/mypath/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(MXNDArrayReshape+0x8c6)
[0x7f3b0ed760b6]
[bt] (4) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c)
[0x7f3b2784fec0]
[bt] (5) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call+0x22d)
[0x7f3b2784f87d]
[bt] (6) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/_ctypes.so(_ctypes_callproc+0x4d6)
[0x7f3b27a65736]
[bt] (7) /home/users/mypath/anaconda2/lib/python2.7/lib-dynload/_ctypes.so(+0x8a61) [0x7f3b27a5ba61]
[bt] (8) /home/users/mypath/anaconda2/bin/../lib/libpython2.7.so.1.0(PyObject_Call+0x43)
[0x7f3b2f75f773]
[bt] (9) /home/users/mypath/anaconda2/bin/../lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x190b)
[0x7f3b2f7f353b]
## Minimum reproducible example
(If you are using your own code, please provide a short script that reproduces the error.
Otherwise, please provide link to the existing example.)
`a = mx.nd.array([[1,2,3],[4,5,6]])`
`a.reshape((1,2,3)) # success`
`a.reshape((-4,1,2,-2)) # fail`
`a.reshape((1,2,-3)) # fail`
## Steps to reproduce
(Paste the commands you ran that produced the error.)
1. Just import mxnet as mx. Then run the above mentioned code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
|