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/02/27 23:16:57 UTC

[GitHub] stephenrawls commented on issue #14264: nd.reshape truncate values

stephenrawls commented on issue #14264: nd.reshape truncate values
URL: https://github.com/apache/incubator-mxnet/issues/14264#issuecomment-468069818
 
 
   Not sure about others but I like this behavior.
   
   It allows me to create a maximum-sized array in imperative mode, and re-shape it to the right size each time through the loop at zero cost and with zero allocations.
   
   When running in training mode with autograd this will give you the error you want though:
   
   ```
   >>> import mxnet as mx
   >>> x = mx.nd.random.randn(10)
   >>> x.reshape(1,2)
   
   [[1.1630787 0.4838046]]
   <NDArray 1x2 @cpu(0)>
   >>> with mx.autograd.record():
   ...   x.reshape(1,2)
   ... 
   Traceback (most recent call last):
     File "<stdin>", line 2, in <module>
     File "/usr/local/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py", line 1062, in reshape
       ctypes.byref(handle)))
     File "/usr/local/lib/python3.7/site-packages/mxnet/base.py", line 251, in check_call
       raise MXNetError(py_str(_LIB.MXGetLastError()))
   mxnet.base.MXNetError: [15:15:07] src/ndarray/ndarray.cc:229: Check failed: shape_.Size() == shape.Size() (10 vs. 2) NDArray.Reshape: target shape must have the same size as current shape when recording with autograd.
   ```

----------------------------------------------------------------
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