Search⌘ K
AI Features

Decoding Output

Explore how to implement the decoding step in Seq2Seq models, retrieve logits during training, and manage output sequence length to improve natural language processing tasks such as text summarization.

Chapter Goals:

  • Retrieve the decoder outputs and return the model's logits during training

After creating the decoder object for our model, we can perform the decoding using the decoder object as dynamic_decode function.

Python 3.5
import tensorflow as tf
extended_vocab_size = 500
batch_size = 10
# decoder is a BasicDecoder object used as Dynamic_decoder
outputs = decoder(inputs , initial_state=initial_state , sequence_length=input_seq_lens , training=True )
decoder_output = outputs[0]
logits = decoder_output.rnn_output
decoder_final_state = outputs[1]
decoded_sequence_lengths = outputs[2]

The decoder object takes in input, initial_state, sequence_length, and isTraining as required argument. It returns a tuple containing three elements:

  1. The decoder's output. For a BasicDecoder input, the decoder's output takes the form of a BasicDecoderOutput object.

  2. The decoder's final state. This isn't ...