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