I have a matrix called POS which has form (10,132) and I need to average those first 10 elements in such a way that my averaged matrix has the form of (1,132)
I have tried doing
means = pos.mean (axis = 1)
or
menas = np.mean(pos)
but the result in the first case is a matrix of (10,) and in the second it is a simple number
i expect the ouput a matrix of shape (1,132)
The solution is to specify the correct axis and use keepdims=True
which is noted by several commenters.
This can be done with either pos.mean(axis = 0,keepdims=True)
or np.mean(pos,axis=0,keepdims=True)