Giter Site home page Giter Site logo

billpei / memn2n-tensorflow-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 1202kbs/memn2n-tensorflow

0.0 1.0 0.0 13.82 MB

Implementation of End-To-End Memory Networks with Tensorflow for bAbI Dataset

Jupyter Notebook 65.57% Python 34.43%

memn2n-tensorflow-1's Introduction

End-To-End Memory Networks in Tensorflow

Tensorflow implementation of End-To-End Memory Networks for synthetic question and answering experiments (see Section 4). The original torch code from Facebook can be found here.

alt tag

Prerequisites

This code requires Tensorflow. The bAbI dataset is stored in the 'bAbI' directory. The original files can be downloaded from here.

If you want to use --show_progress True option, you need to install python package progress.

$ pip install progress

Usage

To train a model with 3 hops and memory size of 50, run the following command:

$ python main.py --nhop 3 --mem_size 50

To see all training options, run:

$ python main.py --help

which will print:

usage: main.py [-h] [--edim EDIM] [--nhop NHOP] [--mem_size MEM_SIZE]
           [--batch_size BATCH_SIZE] [--nepoch NEPOCH]
           [--anneal_epoch ANNEAL_EPOCH] [--babi_task BABI_TASK]
           [--init_lr INIT_LR] [--anneal_rate ANNEAL_RATE]
           [--init_mean INIT_MEAN] [--init_std INIT_STD]
           [--max_grad_norm MAX_GRAD_NORM] [--data_dir DATA_DIR]
           [--checkpoint_dir CHECKPOINT_DIR] [--lin_start [LIN_START]]
           [--nolin_start] [--is_test [IS_TEST]] [--nois_test]
           [--show_progress [SHOW_PROGRESS]] [--noshow_progress]

optional arguments:
  -h, --help              show this help message and exit
  --edim EDIM             internal state dimension [20]
  --nhop NHOP             number of hops [3]
  --mem_size MEM_SIZE     maximum number of sentences that can be encoded into
                          memory [50]
  --batch_size BATCH_SIZE
                          batch size to use during training [32]
  --nepoch NEPOCH         number of epoch to use during training [100]
  --anneal_epoch ANNEAL_EPOCH
                          anneal the learning rate every <anneal_epoch> epochs
                          [25]
  --babi_task BABI_TASK
                          index of bAbI task for the network to learn [1]
  --init_lr INIT_LR       initial learning rate [0.01]
  --anneal_rate ANNEAL_RATE
                          learning rate annealing rate [0.5]
  --init_mean INIT_MEAN
                          weight initialization mean [0.]
  --init_std INIT_STD     weight initialization std [0.1]
  --max_grad_norm MAX_GRAD_NORM
                          clip gradients to this norm [40]
  --data_dir DATA_DIR     dataset directory [./bAbI/en_valid]
  --checkpoint_dir CHECKPOINT_DIR
                          checkpoint directory [./checkpoints]
  --lin_start [LIN_START]
                          True for linear start training, False for otherwise [False]
  --nolin_start
  --is_test [IS_TEST]     True for testing, False for training [False]
  --nois_test
  --show_progress [SHOW_PROGRESS] print progress [False]
  --noshow_progress

(Optional) If you want to see a progress bar, install progress with pip:

$ pip install progress
$ python main.py --nhop 3 --mem_size 50 --show_progress True

After training is finished, you can test and validate with:

$ python main.py --is_test True --show_progress True

Acknowledgements

Majority of the source code in model.py is from: Taehoon Kim / @carpedm20.

The functions for reading the bAbI dataset and feeding it to the graph was modified. Also, the variable and operation names were modified for the ease of comparing the source code and the original paper.

memn2n-tensorflow-1's People

Contributors

1202kbs avatar jaejun-yoo avatar

Watchers

 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.