luke
2018-05-22 12:56:07 UTC
Hi all,
I want to achieve a "broadcast batched dot" operation in theano, such that
the two arguments A and B with shapes
A.shape = [2,5,7,3]
B.shape = [5,3,6]
produce an output C of shape tensor4 [2,5,7,6], with a np equivalent of:
for i in range(A.shape[0]):
for j in range(A.shape[1]):
C[i,j,:,:] = np.dot( A[i,j,:,:], B[j,:,:] )
So, basically, the last two dimensions of A and B are multiplied together
with dot, dimension 1 of A and 0 of B are batched, and dimension 0 of A is
broadcasted onto B.
I've played around a bit with T.batched_tensordot, but could not achieve
this.
The only way I could make this work involves a scan over dimension 0 of A,
and a T.batched_dot over the remaining 3 dimensions. But this is of course
dauntingly slow.
Any ideas?
br,
Luke
I want to achieve a "broadcast batched dot" operation in theano, such that
the two arguments A and B with shapes
A.shape = [2,5,7,3]
B.shape = [5,3,6]
produce an output C of shape tensor4 [2,5,7,6], with a np equivalent of:
for i in range(A.shape[0]):
for j in range(A.shape[1]):
C[i,j,:,:] = np.dot( A[i,j,:,:], B[j,:,:] )
So, basically, the last two dimensions of A and B are multiplied together
with dot, dimension 1 of A and 0 of B are batched, and dimension 0 of A is
broadcasted onto B.
I've played around a bit with T.batched_tensordot, but could not achieve
this.
The only way I could make this work involves a scan over dimension 0 of A,
and a T.batched_dot over the remaining 3 dimensions. But this is of course
dauntingly slow.
Any ideas?
br,
Luke
--
---
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 theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
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 theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.