ruby - NMatrix division of arrays with different shapes -


i have nmatrix array this

x = nmatrix.new([3, 2], [3, 5, 5, 1, 10, 2], dtype: :float64) 

i want divide each column maximum value along column.

using numpy achieved this

y = np.array(([3,5], [5,1], [10,2]), dtype=float) y = y / np.amax(y, axis = 0) 

but nmatrix throws error when try this

x = x / x.max left- , right-hand sides of operation must have same shape. (argumenterror) 

edit

i'm trying follow this tutorial. , scale input, tutorial divides each column maximum value in column. question how achieve step using nmatrix.

my question how achieve same nmatrix.

thanks!

a generic column-oriented approach:

> x = nmatrix.new([3, 2], [3, 5, 5, 1, 10, 2], dtype: :float64)  > x.each_column.with_index |col,j|     m=col[0 .. (col.rows - 1)].max[0,0]     x[0 .. (x.rows - 1), j] /= m   end  > pp x  [   [0.3, 1.0]   [0.5, 0.2]   [1.0, 0.4] ] 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -