You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/11/19 17:04:29 UTC
[GitHub] [incubator-mxnet] Kh4L opened a new pull request #16854: Change
Reshape's shape size check to EQ
Kh4L opened a new pull request #16854: Change Reshape's shape size check to EQ
URL: https://github.com/apache/incubator-mxnet/pull/16854
## Description ##
Change non-recorded `NDArray::Reshape` to accept only shapes with the same volume, in order to match NumPy behavior.
NumPy behavior:
```
>>> a = np.ones(shape=(2,4))
>>> a
array([[1., 1., 1., 1.],
[1., 1., 1., 1.]])
>>> a.reshape(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot reshape array of size 8 into shape (1,)
```
MXNet behavior prior to the change:
```
>>> a = mx.nd.ones(shape=(2,4))
>>> a.reshape(1)
[1.]
<NDArray 1 @cpu(0)>
```
MXNet behavior after the change:
```
>>> a = mx.nd.ones(shape=(2,4))
>>> a.reshape(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/mxnet/python/mxnet/ndarray/ndarray.py", line 1067, in reshape
ctypes.byref(handle)))
File "/opt/mxnet/python/mxnet/base.py", line 252, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [17:03:38] src/ndarray/ndarray.cc:239: Check failed: shape_.Size() == shape.Size() (8 vs. 1) : NDArray.Reshape: target shape must have the same size as current shape.
```
## Checklist ##
### Essentials ###
- [X] Changes are complete (i.e. I finished coding on this PR)
- [X] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
### Changes ###
- [X] Change Reshape check
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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