mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Not able to able to understand mx.symbol.take()? Example

Open chowkamlee81 opened this issue 9 years ago • 7 comments

eq_flag = mx.sym.Variable(name="eq_flag") select_conv_feat = mx.sym.take(mx.sym.Concat(*[warp_conv_feat, conv_feat], dim=0), eq_flag).

What is the dimension of select_conv_feat in terms of (N,C,H,W) Inp : warp_conv_feat (1,1024,48,64) conv_feat(1,1024,48,64) After concat symbol, result dim becomes (2,1024,48,64). Now what is the output of 'select_conv_feat' symbol after going through mx.sym.take function. Iam not able to understand. Kindly help please

chowkamlee81 avatar Nov 29 '17 14:11 chowkamlee81

You can first consider the ndarray that take is operating on as a matrix (2D). If it's more than 2D, flatten it into 2D by keeping the first dim and collapsing all the rest dims into the second dim. For a 2D ndarray (matrix), take op simply extracts the rows specified by the index array and stack them one by one to form an output ndarray.

In your case, let's say eq_flag shape is (4,), then the output of the take has shape (4, 1024, 48, 64).

reminisce avatar Nov 29 '17 17:11 reminisce

Thanks for the kind suggestions. I had one more query. Suppose the shape of 'eq_flag' is (1,) and the value i pass is either '0'/'1'. In this case 'mx.sym.take' will act as a switch to select either 'warp_conv_feat'/'conv_feat'? Kindly provide the suggestions and do the needful.

chowkamlee81 avatar Nov 30 '17 03:11 chowkamlee81

@reminisce any updates from your end. Pls let me know this issue.

chowkamlee81 avatar Dec 13 '17 11:12 chowkamlee81

I don't quite understand your need, but it doesn't look like the behavior you want by using take. The functionality of this op is explained in the documentation. https://mxnet.incubator.apache.org/api/python/ndarray/ndarray.html?highlight=take#mxnet.ndarray.take

If it is not what you need, post your question here so that people can help from there. https://discuss.mxnet.io/

reminisce avatar Dec 14 '17 04:12 reminisce

Proposed Labels : "Example", "Question", "NDArray"

harshitajain1994 avatar Mar 10 '18 00:03 harshitajain1994

Can you please ask usage related questions at - https://discuss.mxnet.io/ Please feel free to reopen if you encounter any issues.

sandeep-krishnamurthy avatar Mar 11 '18 09:03 sandeep-krishnamurthy

What is the difference between this and NDarray.take function?

dheeraj-coding avatar Aug 12 '19 12:08 dheeraj-coding