T
TG
Hi there.
I want to do some intensive computations with numpy, and I'm
struggling a bit to find myyyyy wayyyyyy. Here is the problem :
m and d are two matrices :
I want to return
I already found that
Now I want to sum up on axis 2 and 3. If I do :
I'm wondering : is this syntax leading to efficient computation, or is
there something better ?
thanks
Thomas
I want to do some intensive computations with numpy, and I'm
struggling a bit to find myyyyy wayyyyyy. Here is the problem :
m and d are two matrices :
m.shape = (x,y,a,b)
d.shape = (a,b)
I want to return
i.shape = (x,y) with
i[x,y] = sum(m[x,y] * d)
I already found that
will give me a matrix of shape (x,y,a,b) containing the products.m[:,:] * d
Now I want to sum up on axis 2 and 3. If I do :
it seems like I get my result.(m[:,:] * d).sum(axis=3).sum(axis=2)
I'm wondering : is this syntax leading to efficient computation, or is
there something better ?
thanks
Thomas