Code Monkey home page Code Monkey logo

pytorch-seq2seq-encoder-decoder's Introduction

PyTorch-Sequence-to-Sequence

Arabic to English Translation using Encoder-Decoder Sequence-to-Sequence Model

To run

  1. Install PyTorch from https://pytorch.org/get-started/locally/ (default below) and other dependencies

     $ pip install torch torchvision matplotlib
    
  2. [Optional] Install latest PyTorch-NLP if using attention

     $ pip install git+https://github.com/PetrochukM/PyTorch-NLP
    
  3. Run train.py

     $ python train.py -h
     usage: train.py [-h] [-data DATA] [-embeddings_size EMBEDDINGS_SIZE]
                 [-layers LAYERS] [-hidden_sizes HIDDEN_SIZES]
                 [-dropout DROPOUT] [-epochs EPOCHS] [-optimizer {sgd,adam}]
                 [-learning_rate LEARNING_RATE] [-l2_decay L2_DECAY]
                 [-batch_size BATCH_SIZE] [-cuda] [-name NAME] [-quiet] [-tqdm]
                 [-display_vocabularies] [-reverse_source_string]
                 [-bidirectional] [-attention {dot,general}]
    
train.py

Main script, loads the dataset and trains the model. Plots both the training losses and validation accuracies and returns the final test accuracy.

model.py

Encoder-Decoder model implemented in PyTorch. Also contains the training and evaluation utilities.

dataset.py

Ar2EnDataset and simple Vocabulary class.

Optional Arguments
$ python train.py

-h, --help            show this help message and exit
-data DATA            Path to ar2en dataset.

-embeddings_size EMBEDDINGS_SIZE
-layers          LAYERS
-hidden_sizes    HIDDEN_SIZES
-dropout         DROPOUT
-epochs          EPOCHS
-optimizer       {sgd,adam}
-learning_rate   LEARNING_RATE
-l2_decay        L2_DECAY
-batch_size      BATCH_SIZE
-attention       {dot,general} -> Requires installing the latest version of PyTorch-NLP from git

-cuda                     Whether or not to use cuda for parallelization (if devices available)
-name NAME                Filename for the plot 
-quiet                    No execution output.
-tqdm                     Whether or not to use TQDM progress bar in training.
-display_vocabularies     Only display the vocabularies (no further execution).
-reverse_source_string    Whether or not to reverse the source arabic string.
-bidirectional            Whether or not to use a bidirectional LSTM encoder.

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.