Sequence-to-Sequence model

In this section, we'll implement a seq2seq model (an Encoder-Decoder RNN) based on the LSTM unit for a simple sequence to sequence question answer task.  This model can be trained to map an input sequence (questions) to an output sequence (answers) which is not necessarily of the same length.

This type of seq2seq model has shown impressive performance in various other tasks such as speech recognition, machine translation, question answering, Neural Machine Translation and Image Caption generation.

The following image helps us visualize our seq2seq model:

In the encoder-decoder structure, one RNN (blue) encodes the input sequence. The encoder emits the context C, usually as simple function of its final hidden state. And the second RNN (red) decoder calculate the target values and generates the output sequence.  One essential step is to let the encoder and decoder communicate. In the simplest approach, you use the last hidden state of the encoder to initialize the decoder.  Other approaches let the decoder attend to different parts of the encoded input at different timesteps in the decoding process.

So let's get started with data preparation, model building, training, tuning, and evaluating our seq2seq model and see how it performs

Link for the model can be found at:https://github.com/PacktPublishing/Python-Deep-Learning-Projects/blob/master/Chapter%205/3.%20rnn_lstm_seq2seq.py

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.70.38