I am reading the mxnet tutorial on NDarray part and I am confused about the use of sum_axis
function and the example is :
>>> a = mx.nd.ones((2,3))
>>> c = mx.nd.sum_axis(a, axis=1)
>>> c.asnumpy()
array([ 3., 3.], dtype=float32)
>>> c = mx.nd.sum_axis(a, axis=0)
>>> c.asnumpy()
array([ 2., 2., 2.], dtype=float32)
What I am wondering is when the value of paramter axis
is 1
, I think it should output
array([ 2., 2., 2.], dtype=float32)
but not
array([ 3., 3.], dtype=float32)
As when the value of paramter axis
is 1
, I think the sum_axis
should compute the sum along the column ,but the result shows it compute the sum along the rows.
And it seems that numpy
also compute like this and I really don't understand why this way.
So anyone could explain this ?
Thanks!!