title: How to compute weighted average of tensor A along an axis with weights specified by tensor B in tensorflow?
body: <p>I am trying to apply a weighted average scheme on RNN output.<br>
  RNN output is represented by tensor <code>A</code> having dimension <code>(a,b,c)</code>.<br>
  I can simply take <code>tf.reduce_mean(A,axis=1)</code> to get the tensor <code>C</code> having dimension <code>(a,c)</code>.  </p>
  
  <p>However, I want to do the "weighted average" of tensor <code>A</code> along <code>axis = 1</code>.<br>
  Weights are specified in the matrix <code>B</code> having dimension <code>(d,b)</code>.  </p>
  
  <p>For <code>d = 1</code>, I can do <code>tf.tensordot(A,B,[1,1])</code> to get the result of dimension <code>(a,c)</code>.<br>
  Now for <code>d=a</code>, I am unable to compute the weighted average.</p>
  
  <p>Can someone suggest a solution?</p>