How to get the last output?
qtcv opened this issue · comments
In dynamic_rnn.ipynb, you can get the last ouput by result[0]["outputs"][1,6]
but in most cases, the last output index could be variable, How to get the last outputs in a batch?
You can index it by example length. result[0]["outputs"][1,example_length[1]]
Alternatively you can use the last state that is returned, in some cases state and output are the same (i.e. GRU), and in some cases (LSTM) the output is a subset of the state, e.g. for an LSTM:output = state.m
Thanks, there is another solution: https://danijar.com/variable-sequence-lengths-in-tensorflow/
I think you are confusing two different things. What you quote about is in Python after you fetched values from the Tensoflow graph. What you link to is (a rather bad way) of doing it in-graph. Anyway, closing this for now.