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 2020/04/25 00:44:27 UTC

[GitHub] [incubator-mxnet] roywei opened a new issue #18165: Unknown shape in flatten op.

roywei opened a new issue #18165:
URL: https://github.com/apache/incubator-mxnet/issues/18165


   Right now there is no way to represent unknown shape in MXNet 
   
   According to https://github.com/apache/incubator-mxnet/issues/14253, now it use -1 instead of 0 as unknown dim. This should only take effect if `mx.npx.set_np()` is used.
   
   I have the following use case when I want to bind a shape with unknown batch size, and feed different batch size data during forward.
   ```
   import mxnet as mx
   a = mx.sym.Variable("a")
   b = mx.sym.Flatten(a)
   exec = b.simple_bind(ctx=mx.cpu(), a=(0,10,2))
   ```
   if give the following error:
   ```
   Traceback (most recent call last):
     File "//anaconda3/lib/python3.7/site-packages/mxnet/symbol/symbol.py", line 1780, in simple_bind
       ctypes.byref(exe_handle)))
     File "//anaconda3/lib/python3.7/site-packages/mxnet/base.py", line 246, in check_call
       raise get_last_ffi_error()
   mxnet.base.MXNetError: Traceback (most recent call last):
     File "src/executor/../common/exec_utils.h", line 391
   MXNetError: InferShape pass cannot decide shapes for the following arguments (-1 means unknown dimensions). Please consider providing them as inputs:
   a: [-1,10,2],
   ```
   
   But if I use -1,  it also fails no matter if set_np() is used.
   ```
   >>> exec = b.simple_bind(ctx=mx.cpu(), a=(-1, 10,2))
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "//anaconda3/lib/python3.7/site-packages/mxnet/symbol/symbol.py", line 1758, in simple_bind
       array('I', provided_arg_shape_data)),
   OverflowError: can't convert negative value to unsigned int
   ```


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



[GitHub] [incubator-mxnet] apeforest commented on issue #18165: Unknown shape in flatten op.

Posted by GitBox <gi...@apache.org>.
apeforest commented on issue #18165:
URL: https://github.com/apache/incubator-mxnet/issues/18165#issuecomment-636421018


   It works with the np_shape API:
   
   ```
   import mxnet as mx
   with mx.np_shape(active=True):
       a = mx.sym.Variable("a")
       b = mx.sym.Flatten(a)
       exec = b.simple_bind(ctx=mx.cpu(), a=(0,10,2))
   ```


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



[GitHub] [incubator-mxnet] roywei commented on issue #18165: Unknown shape in flatten op.

Posted by GitBox <gi...@apache.org>.
roywei commented on issue #18165:
URL: https://github.com/apache/incubator-mxnet/issues/18165#issuecomment-653226815


   I think it still fails for unknow shape case. The above code works fine for 0 dim, but use -1 to represent unknown shape still fails:
   ```
   >>> with mx.np_shape(active=True):
   ...     a = mx.sym.Variable("a")
   ...     b = mx.sym.Flatten(a)
   ...     exec = b.simple_bind(ctx=mx.cpu(), a=(-1,10,2))
   ...     exec.forward(a=mx.nd.ones((32,10,2)))
   ...
   Traceback (most recent call last):
     File "<stdin>", line 4, in <module>
     File "//anaconda3/lib/python3.7/site-packages/mxnet/symbol/symbol.py", line 1754, in simple_bind
       array('I', provided_arg_shape_data)),
   OverflowError: can't convert negative value to unsigned int
   
   ```


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



[GitHub] [incubator-mxnet] apeforest edited a comment on issue #18165: Unknown shape in flatten op.

Posted by GitBox <gi...@apache.org>.
apeforest edited a comment on issue #18165:
URL: https://github.com/apache/incubator-mxnet/issues/18165#issuecomment-636421018


   It works with the np_shape API. @reminisce @haojin2 Is this by design that requires the np_shape API for backward compatibility? Thanks.
   
   ```
   import mxnet as mx
   with mx.np_shape(active=True):
       a = mx.sym.Variable("a")
       b = mx.sym.Flatten(a)
       exec = b.simple_bind(ctx=mx.cpu(), a=(0,10,2))
   ```


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