title: Double dot product with broadcasting in numpy
body: <p>I have the following operation :</p>
  
  <pre><code>import numpy as np
  
  x = np.random.rand(3,5,5)
  w = np.random.rand(5,5)
  
  y=np.zeros((3,5,5))
  for i in range(3):
      y[i] = np.dot(w.T,np.dot(x[i],w))
  </code></pre>
  
  <p>Which corresponds to the pseudo-expression <code>y[m,i,j] = sum( w[k,i] * x[m,k,l] * w[l,j], axes=[k,l]</code> or equivalently simply the dot product of <code>w.T</code> , <code>x</code>, <code>w</code> broadcaster over the first dimension of <code>x</code>. </p>
  
  <p>How can I implement it with numpy's broadcasting rules ?</p>
  
  <p>Thanks in advance.</p>