title: Tensor contraction in tensorflow
body: <p>I have a tensor <code>weights</code> of shape <code>(?,4)</code> and a tensor <code>embeddings</code> of shape <code>(?,4,1024)</code>.</p>
  
  <p>I would like to contract the tensor by taking a weighted mean of the 4 tensors in each row of <code>embeddings</code> according to the corresponding <code>weights</code>, finally producing a tensor <code>output</code> of shape <code>(?,1024)</code>.</p>
  
  <p>How can I do that? I tried with <code>output = tf.tensordot(weights, embeddings, axes = [1,1])</code> but that produced a tensor of shape <code>(?,?,1024)</code> instead.</p>