[Numpy-discussion] Tensor-Like Outer Product Question
matt_in_nyc
mkraning@gmail....
Tue Aug 3 15:16:54 CDT 2010
I am trying to perform the following operation:
X is an m by n matrix, and I want to store outer products of the form Y[i] =
numpy.outer(X[i,:], X[i,:]), leading to the relation Y[i,j,k] =
X[i,j]*X[i,k] for i = 0,...,m-1; j,k = 0,...,n-1. I am trying to think of
how to do this using tensordot, but so far I am finding no inspiration.
Some far, my only solution has been to loop over i
Y = numpy.empty([m,n,n])
for i in range(m):
Y[i] = numpy.outer(X[i,:], X[i,:])
but this is fairly slow as for my dataset, m is of order 10^7 or 10^8 and n
is around 20. Any help on how to vectorize/tensorize this operation to
avoid the for loop would be much appreciated.
--
View this message in context: http://old.nabble.com/Tensor-Like-Outer-Product-Question-tp29339226p29339226.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
More information about the NumPy-Discussion
mailing list