question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implementing Seq2Seq Models

See original GitHub issue

A 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, to Recurrent.call.
  • #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 to Recurrent.__init__. If True, 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.
  • #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 to Recurrent.__init__. It requires unroll=True. If output_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.

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.

@farizrahman4u @fchollet @israelg99.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
fcholletcommented, Mar 13, 2017

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).

5reactions
jinfagangcommented, Jul 1, 2017

Has official keras contains seq2seq implementation now?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found