You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/09/24 15:01:30 UTC

[GitHub] [incubator-mxnet] duothink opened a new issue #19217: how to take specific data from 3 dims NDArray?

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


   ## Description
   ```
   from mxnet import nd
   
   #x is 2x3x4 
   x = nd.array([
       [
           [1,2,3,4],
           [5,6,7,8],
           [9,10,11,12]
       ],
       [
           [13,14,15,16],
           [17,18,19,20],
           [21,22,23,24]
       ]
   ])
   idx = nd.array([0,2])
   y = x.take(idx,axis=1)
   print(y)
   ```
   out is :
   [[[ 1.  2.  3.  4.]
     [ 9. 10. 11. 12.]]
   
    [[13. 14. 15. 16.]
     [21. 22. 23. 24.]]]
   <NDArray 2x2x4 @cpu(0)>
   
   how can I get a NDArray 2x1x4 as below
   [
   [ [1,2,3,4] ],
   [ [21,22,23,24] ]
   ]
   
   
   


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] github-actions[bot] commented on issue #19217: how to take specific data from 3 dims NDArray?

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #19217:
URL: https://github.com/apache/incubator-mxnet/issues/19217#issuecomment-698402244


   Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
   Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
   If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on [contributing to MXNet](https://mxnet.apache.org/community/contribute) and our [development guides wiki](https://cwiki.apache.org/confluence/display/MXNET/Developments).


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] szha closed issue #19217: how to take specific data from 3 dims NDArray?

Posted by GitBox <gi...@apache.org>.
szha closed issue #19217:
URL: https://github.com/apache/incubator-mxnet/issues/19217


   


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] szha commented on issue #19217: how to take specific data from 3 dims NDArray?

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


   Hi, I think what you need is gather_nd
   ```
   x = nd.array([
       ...:     [
       ...:         [1,2,3,4],
       ...:         [5,6,7,8],
       ...:         [9,10,11,12]
       ...:     ],
       ...:     [
       ...:         [13,14,15,16],
       ...:         [17,18,19,20],
       ...:         [21,22,23,24]
       ...:     ]
       ...: ])
       ...: idx = nd.array([[0, 1], [0, 2]])
       ...: y = nd.gather_nd(x, idx)
       ...: print(y)
       ...:
   
   [[ 1.  2.  3.  4.]
    [21. 22. 23. 24.]]
   <NDArray 2x4 @cpu(0)>
   ```


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] szha commented on issue #19217: how to take specific data from 3 dims NDArray?

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


   Hi, I think what you need is gather_nd
   ```
   x = nd.array([
       ...:     [
       ...:         [1,2,3,4],
       ...:         [5,6,7,8],
       ...:         [9,10,11,12]
       ...:     ],
       ...:     [
       ...:         [13,14,15,16],
       ...:         [17,18,19,20],
       ...:         [21,22,23,24]
       ...:     ]
       ...: ])
       ...: idx = nd.array([[0, 1], [0, 2]])
       ...: y = nd.gather_nd(x, idx)
       ...: print(y)
       ...:
   
   [[ 1.  2.  3.  4.]
    [21. 22. 23. 24.]]
   <NDArray 2x4 @cpu(0)>
   ```


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] szha closed issue #19217: how to take specific data from 3 dims NDArray?

Posted by GitBox <gi...@apache.org>.
szha closed issue #19217:
URL: https://github.com/apache/incubator-mxnet/issues/19217


   


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] github-actions[bot] commented on issue #19217: how to take specific data from 3 dims NDArray?

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #19217:
URL: https://github.com/apache/incubator-mxnet/issues/19217#issuecomment-698402244


   Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
   Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
   If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on [contributing to MXNet](https://mxnet.apache.org/community/contribute) and our [development guides wiki](https://cwiki.apache.org/confluence/display/MXNET/Developments).


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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org