title: How to multiply Tensors in Theano
body: <p>I have two tensors and a weight matrix in Theano. 
  Tensor A has dimension (k, 5, 40). Tensor B has dimension (k, 5, 40). Weight matrix W has dimension (40,40). I would like to compute
  A<em>W</em>B. What is the correct sequence of Theano tensor operations to achieve this? Note that k can vary during run time but other dimensions are fixed.
  The semantics we want from A<em>W</em>B is the following:</p>
  
  <p>Think of A as a collection of k (5,40) matrices. Call them A_1, ..., A_k
  Think of B as a collection of k (5,40) matrices. Call them B_1, ..., B_k.
  We want to find A_{i} * W * B_{i}^{T} for all i from 1 to k. I tried using theano.tensor.dot but it seems quite confusing.</p>
  
  <p>Note that a non-efficient way of doing this is to use the scan function. But this would make an inherently parallel code sequential.</p>