dennybritz / tf-rnn

Practical Examples for RNNs in Tensorflow

Home Page:http://www.wildml.com/2016/08/rnns-in-tensorflow-a-practical-guide-and-undocumented-features/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get the last output?

qtcv opened this issue · comments

commented

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

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.