GithubHelp home page GithubHelp logo

wavelets / seq2seq Goto Github PK

View Code? Open in Web Editor NEW

This project forked from farizrahman4u/seq2seq

0.0 2.0 0.0 57 KB

Sequence to Sequence Learning with Keras

License: GNU General Public License v2.0

Python 100.00%

seq2seq's Introduction

seq2seq

Sequence to Sequence Learning with Keras

Papers:

seq2seq

Notes:

  • The LSTM Encoder encodes a sequence to a single a vector.

  • The LSTM Decoder, when given a hidden state and a vector, generates a sequence.

  • In the Seq2seq model, the output vector of the LSTM Encoder is the input for the LSTM Decoder, and

  • The hidden state of the LSTM Encoder is copied to the hidden state of LSTM Decoder.

Continious VS Descrete sequence pairs:

  • When training on continuous sequence pairs, such as long conversations, use the Conversational model instead of Seq2seq model, with argument context_sensitive=True. This is important if you want context sensitive conversational models, so that you can avoid scenarios like this:(Will only work if there are lot of exchanges in each conversation in your training data)

Human: what is your job ?

Machine: i ’m a lawyer .

Human: what do you do ?

Machine: i ’m a doctor

Source : A Neural Conversational Model

  • When context_sensitive=True do not forget to clear the hidden state of Conversational layer after every conversation(Not after every exchange) or a fixed number of batches using reset_hidden_state() during training and testing. You could use the ResetState callback for this purpose.

  • You will also have to clear the hidden state of Seq2seq layer after a fixed number of batches when used with remember_state=True.

  • In case of descrete sequence pairs(for e.g, machine translation) use Seq2seq layer with the remeber_state argument set to False.

Example:

import keras
from keras.models import Sequential
from keras.layers.embeddings import Embedding
from seq2seq.seq2seq import Seq2seq
from keras.preprocessing import sequence

vocab_size = 20000 #number of words
maxlen = 100 #length of input sequence and output sequence
embedding_dim = 200 #word embedding size
hidden_dim = 500 #memory size of seq2seq

embedding = Embedding(vocab_size, embedding_dim, input_length=maxlen)
seq2seq = Seq2seq(input_length=maxlen, input_dim=embedding_dim,hidden_dim=hidden_dim,
                  output_dim=embedding_dim, output_length=maxlen, batch_size=10, depth=4)

model = Sequential()
model.add(embedding)
model.add(seq2seq)

Installation:

sudo pip install git+ssh://github.com/farizrahman4u/seq2seq.git

Requirements:

Working Example:

seq2seq's People

Contributors

farizrahman4u avatar libraua avatar nicolas-ivanov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.