Implementing Seq2Seq Models
See original GitHub issueA number of us have shown interest in implementing seq2seq models in Keras #5358, so I’m creating a central issue for it. We can discuss design decisions and prevent duplication of work here.
There are a number of existing pull requests related to seq2seq models:
- #5559 (Merged) Specify States of RNN Layers Symbolically.
- We have to specify the initial state of the decoder symbolically. This pull request adds the
initial_state
argument, which is either a tensor or list of tensors, toRecurrent.call
.
- We have to specify the initial state of the decoder symbolically. This pull request adds the
- #5731 Add
return_state
flag to RNNs for seq2seq modeling.- We have to retrieve the final state of encoder. This pull request adds the
return_state
flag toRecurrent.__init__
. IfTrue
, the output of the RNN will be a list of tensors. The first tensor is the output, and the remaining tensors are the final state.
- We have to retrieve the final state of encoder. This pull request adds the
- #5737 Implement RNN decoding; feed output t-1 as input t
- During test time, we have to feed the output of the decoder back into itself as the input for the next time step. This pull request adds the
output_length
argument toRecurrent.__init__
. It requiresunroll=True
. Ifoutput_length
is greater than the length of the input, the output of that layer will be fed back into the RNN as the input for the next time step. - Note: During training time, we can use teacher forcing, instead of feeding back the outputs of the decoder.
- During test time, we have to feed the output of the decoder back into itself as the input for the next time step. This pull request adds the
There is currently a seq2seq example in keras/examples
: addition_rnn.py
. However, the implementation could be greatly improved. It currently supports only a single layer encoder-decoder architecture. It also does not perform teacher forcing.
Feel free to comment on any ideas, questions or comments you might have.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:14 (6 by maintainers)
Top Results From Across the Web
How to Implement Seq2seq Model - Cnvrg.io
In this section we will learn how to implement the Seq2Seq model from scratch. We will be using the pytorch framework to implement...
Read more >How to implement Seq2Seq LSTM Model in Keras
Seq2Seq is a type of Encoder-Decoder model using RNN. It can be used as a model for machine interaction and machine translation. By...
Read more >Seq2seq (Sequence to Sequence) Model with PyTorch - Guru99
The training process in Seq2seq models is starts with converting each pair of sentences into Tensors from their Lang index. Our sequence to ......
Read more >Introduction to seq2seq models - Jake Tae
Implementation Permalink ... A typical sequence-to-sequence model is, by design, composed of an encoder and a decoder. The encoder takes in a ...
Read more >Implementing a Sequence-to-Sequence Model | HackerNoon
In this section, you will outline the TensorFlow seq2seq model definition. You'll employ an embedding layer to go from integer representation to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I will check out the two PRs after we are done releasing Keras 2. Looking forward to reading everyone’s feedback on how to best handle seq2seq models, API-wise. The first PR was a success (symbolic states).
Has official keras contains seq2seq implementation now?