python - Calculate matrix column mean -


i've got matrix:

      [[[ 0.49757494  0.50242506]       [ 0.50340754  0.49659246]       [ 0.50785456  0.49214544]          ...,        [ 0.50817149  0.49182851]       [ 0.50658656  0.49341344]       [ 0.49419885  0.50580115]]        [[ 0.117       0.883     ]       [ 0.604       0.396     ]       [ 1.          0.        ]          ...,        [ 0.98559675  0.01440325]       [ 0.948       0.052     ]       [ 0.012       0.988     ]]        [[ 0.21099179  0.78900821]       [ 0.75212493  0.24787507]       [ 0.96653919  0.03346081]            ...,        [ 0.97485074  0.02514926]       [ 0.95051503  0.04948497]       [ 0.05409603  0.94590397]]] 

if weights w1,w2,w3, how can calculate mean of first column , second column each matrix (3 2) ? can like:

      [[[(x1        y1]         ...,       [x2           y2]       [[x3          y3]         ..., 

thanks in advance.

edit: input shape (3, 37375, 2), , have instead of (3,2), (1,2). mean each column, example:

   (0.497*w1 + 0.503*w2 + 0.507*w3)/ (w1 + w2 + w3)     <--- first column 

assuming input shape (3,n,2) , want shape (n,3,2) want first do

in=in.reshape((-1,3,2)) 

if have weighting vector w

w = np.random.rand(3) 

then can weighted average on first axis np.average (yielding (n,2)

out1 = np.average(in, weights = w, axis = 1) 

or can weighted sum

out1 = np.sum(t*w[none,:, none], axis = 1) / np.sum(w) 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -