python - Add the elements in a row, for each row, in a matrix, using theano -


i have vector v , matrix z, say

v = theano.shared(rng.normal(0, 1, 10)) z = theano.shared(rng.normal(0, 1, (10, 10))) 

i want create new vector y given v + sum of elements in each row of z. basically: y[i] = v[i] + t.sum(z[:,i]) can do, each entry, by:

y[i] = v[i] + theano.tensor.sum(z[:][i]) 

my question is: there way, without doing loop, write y = v + t.sum(rows of z) in 1 single line?

you can obtain this

y = v + z.sum(axis=1) 

in numpy, , in theano, many aggregator functions, such sum, mean, var, std, any, all, ... have axis keyword argument, , axes keyword argument, can specify in direction array traversed.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -