I am trying to implement my customer layer for neural network using mxnet. I was wondering if there is a function in mxnet similar to np.bincount. If not, is there a way I can calculate it without having to convert my mx.ndarray
to numpy
?
Asked
Active
Viewed 60 times
0

deepAgrawal
- 673
- 1
- 7
- 25
1 Answers
1
MXNet doesn't have such functionality. You can implement it by writing a loop like this:
bins = []
for i in range(max_value):
bins.append(nd.sum(my_array == i))
bins = nd.concat(bins)
Keep in mind that if you use numpy, not only you're switching from GPU context to CPU and slowing down the computation, you also cannot do backprop on the computation.

Sina Afrooze
- 960
- 6
- 11