Hello,

Imagine I run an LSTM on a sequence and receive a vector of outputs of 
length L:

output_hiddens = [h_1,h_2,h_3,....h_L]

I would like to calculate the Cartesian product of itself and pull the 
upper (or lower) triangle of the matrix:

upper_tri_pulled = [(h_1,h_2), (h_1,h_3), ...., (h_L-1,h_L)]

Previously I used Numpy to generate the indices to index into the previous 
1D vector: 

upper_tri_pulled = output_hiddens[np.triu_indices(len(output_hiddens),1)]

But this seems slow, or there as to be a better way to do this.

I can just calculate the whole (LxL) matrix via an outer product, but 
memory is extremely limited, particularly going from a O(N) to a O(N^2) 
regime. Is there a memory-efficient and fast regime to generate this 
upper-triangle?

Thanks!!

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to