Tensor Indexing
Use tensor indexing to retrieve the model's final word prediction.
We'll cover the following...
Chapter Goals:
- Extract the word predictions for the final time step of each sequence
A. Gather functions
When generating word predictions for a batch of sequences, we only want to retrieve the word IDs for each sequence's final time step. If this were regular Python (or NumPy), we could do this through simple list indexing or slicing. However, in TensorFlow we need to use gather functions to retrieve data at specific locations in the tensor.
There are two main gather functions: tf.gather
and ...