lstm - Handling outputs from tf.nn.dynamic_rnn in Tensorflow -


i put 3-layer lstm tf.nn.dynamic_rnn, , have handle output dynamic_rnn in desired way. want let dynamic_rnn output flow fc layers. output dynamic_rnn rank-3 tensor, shape of [batch_size, sequence_length, hidden_dim]. used pass fc layer output[:,-1], shape [batch_size, hidden_dim], since wanted use last output of dynamic_rnn.

but, time want use output of whole sequence, pass output[:] fc layer. not sure how code fc layer part, because output[:] 3-d tensor, , w(weight) should affect evenly on every 2-d tensor, per "batch_size" rank in output.

take @ code tf.layers.dense example of how rank tensor (with innermost depth dimension) can handled in layer. namely: tf.matmul knows how apply matrix multiply 3-tensor proper broadcasting:

tf.matmul(a,w) a shaped [b,t,d] , w shaped [d,e] takes inner product along inner dimensions: output's shape [b,t,e]. adding bias vector, shaped [e], broadcast correctly.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -