• Stars
    star
    826
  • Rank 55,195 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

"End-To-End Memory Networks" in Tensorflow

End-To-End Memory Networks in Tensorflow

Tensorflow implementation of End-To-End Memory Networks for language modeling (see Section 5). The original torch code from Facebook can be found here.

alt tag

Prerequisites

This code requires Tensorflow. There is a set of sample Penn Tree Bank (PTB) corpus in data directory, which is a popular benchmark for measuring quality of these models. But you can use your own text data set which should be formated like this.

When you use docker image tensorflw/tensorflow:latest-gpu, you need to python package future.

$ pip install future

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

$ pip install progress

Usage

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

$ python main.py --nhop 6 --mem_size 100

To see all training options, run:

$ python main.py --help

which will print:

usage: main.py [-h] [--edim EDIM] [--lindim LINDIM] [--nhop NHOP]
              [--mem_size MEM_SIZE] [--batch_size BATCH_SIZE]
              [--nepoch NEPOCH] [--init_lr INIT_LR] [--init_hid INIT_HID]
              [--init_std INIT_STD] [--max_grad_norm MAX_GRAD_NORM]
              [--data_dir DATA_DIR] [--data_name DATA_NAME] [--show SHOW]
              [--noshow]

optional arguments:
  -h, --help            show this help message and exit
  --edim EDIM           internal state dimension [150]
  --lindim LINDIM       linear part of the state [75]
  --nhop NHOP           number of hops [6]
  --mem_size MEM_SIZE   memory size [100]
  --batch_size BATCH_SIZE
                        batch size to use during training [128]
  --nepoch NEPOCH       number of epoch to use during training [100]
  --init_lr INIT_LR     initial learning rate [0.01]
  --init_hid INIT_HID   initial internal state value [0.1]
  --init_std INIT_STD   weight initialization std [0.05]
  --max_grad_norm MAX_GRAD_NORM
                        clip gradients to this norm [50]
  --checkpoint_dir CHECKPOINT_DIR
                        checkpoint directory [checkpoints]
  --data_dir DATA_DIR   data directory [data]
  --data_name DATA_NAME
                        data set name [ptb]
  --is_test IS_TEST     True for testing, False for Training [False]
  --nois_test
  --show SHOW           print progress [False]
  --noshow

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

$ pip install progress
$ python main.py --nhop 6 --mem_size 100 --show True

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

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

The training output looks like:

$ python main.py --nhop 6 --mem_size 100 --show True
Read 929589 words from data/ptb.train.txt
Read 73760 words from data/ptb.valid.txt
Read 82430 words from data/ptb.test.txt
{'batch_size': 128,
'data_dir': 'data',
'data_name': 'ptb',
'edim': 150,
'init_hid': 0.1,
'init_lr': 0.01,
'init_std': 0.05,
'lindim': 75,
'max_grad_norm': 50,
'mem_size': 100,
'nepoch': 100,
'nhop': 6,
'nwords': 10000,
'show': True}
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 12
I tensorflow/core/common_runtime/direct_session.cc:45] Direct session inter op parallelism threads: 12
Training |################################| 100.0% | ETA: 0s
Testing |################################| 100.0% | ETA: 0s
{'perplexity': 507.3536108810464, 'epoch': 0, 'valid_perplexity': 285.19489755719286, 'learning_rate': 0.01}
Training |################################| 100.0% | ETA: 0s
Testing |################################| 100.0% | ETA: 0s
{'perplexity': 218.49577035468886, 'epoch': 1, 'valid_perplexity': 231.73457031084268, 'learning_rate': 0.01}
Training |################################| 100.0% | ETA: 0s
Testing |################################| 100.0% | ETA: 0s
{'perplexity': 163.5527845871247, 'epoch': 2, 'valid_perplexity': 175.38771414841014, 'learning_rate': 0.01}
Training |################################| 100.0% | ETA: 0s
Testing |################################| 100.0% | ETA: 0s
{'perplexity': 136.1443535538306, 'epoch': 3, 'valid_perplexity': 161.62522958776597, 'learning_rate': 0.01}
Training |################################| 100.0% | ETA: 0s
Testing |################################| 100.0% | ETA: 0s
{'perplexity': 119.15373237680929, 'epoch': 4, 'valid_perplexity': 149.00768378137946, 'learning_rate': 0.01}
Training |##############                  | 44.0% | ETA: 378s

Performance

The perplexity on the test sets of Penn Treebank corpora.

# of hidden # of hops memory size MemN2N (Sukhbaatar 2015) This repo.
150 3 100 122 129
150 6 150 114 in progress

Author

Taehoon Kim / @carpedm20

More Repositories

1

awesome-hacking

A curated list of awesome Hacking tutorials, tools and resources
12,576
star
2

DCGAN-tensorflow

A tensorflow implementation of "Deep Convolutional Generative Adversarial Networks"
JavaScript
7,111
star
3

ENAS-pytorch

PyTorch implementation of "Efficient Neural Architecture Search via Parameters Sharing"
Python
2,626
star
4

emoji

emoji terminal output for Python
Python
1,877
star
5

deep-rl-tensorflow

TensorFlow implementation of Deep Reinforcement Learning papers
Python
1,578
star
6

DiscoGAN-pytorch

PyTorch implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"
Jupyter Notebook
1,048
star
7

NTM-tensorflow

"Neural Turing Machine" in Tensorflow
Jupyter Notebook
1,045
star
8

BEGAN-tensorflow

Tensorflow implementation of "BEGAN: Boundary Equilibrium Generative Adversarial Networks"
Python
920
star
9

LINE

May the LINE be with you...
Python
811
star
10

lstm-char-cnn-tensorflow

in progress
Python
756
star
11

awesome-torch

A curated list of awesome Torch tutorials, projects and communities
616
star
12

simulated-unsupervised-tensorflow

TensorFlow implementation of "Learning from Simulated and Unsupervised Images through Adversarial Training"
Python
573
star
13

variational-text-tensorflow

TensorFlow implementation of Neural Variational Inference for Text Processing
Python
545
star
14

pixel-rnn-tensorflow

in progress
Python
495
star
15

visual-analogy-tensorflow

Tensorflow implementation of "Deep Visual Analogy-Making"
Python
289
star
16

BEGAN-pytorch

in progress
Python
262
star
17

NAF-tensorflow

"Continuous Deep Q-Learning with Model-based Acceleration" in TensorFlow
Python
193
star
18

attentive-reader-tensorflow

in progress
Python
189
star
19

korail2

Korail (www.letskorail.com) wrapper for Python.
Python
149
star
20

SPIRAL-tensorflow

in progress
Python
116
star
21

deep-learning-study

Study of HeXA@UNIST in Preparation for Submission
108
star
22

poet-neural

์ธ๊ณต์ง€๋Šฅ ์‹œํŒ”์ด, ์‹œ์ธ ๋‰ด๋Ÿด
CSS
76
star
23

karel

Karel dataset for program synthesis and program induction
Python
76
star
24

program-synthesis-rl-tensorflow

in progress
Python
72
star
25

text-based-game-rl-tensorflow

in progress
Python
61
star
26

paper-notes

personal notes
56
star
27

word2vec-tensorflow

in progress
Python
46
star
28

between

Between of VCNC for Python
Python
38
star
29

a3c-tensorflow

Python
33
star
30

hali

A neural network for question answering model
Lua
32
star
31

ndrive

Python wrapper for NAVER Ndrive
Python
31
star
32

RCMN

Recurrent Convolutional Memory Network (in progress)
Python
29
star
33

board

25
star
34

FoodClassifier

Food image classifier
Python
25
star
35

practice-tensorflow

Jupyter Notebook
20
star
36

reviewduk

Korean Sentiment Analyzer in Morphologically Rich Languages
JavaScript
19
star
37

voxoffice

A Data Visualization of Box Office History.
JavaScript
18
star
38

gornn

Deep Recurrent Neural Networks and Long Short Term Memory in Golang
Go
18
star
39

personal-blog-powered-by-flask

website powered by flask
Python
16
star
40

movieduk

Record the movie list and share it!
Python
15
star
41

movietag

Search movie with tag
CSS
12
star
42

HeXA-Bot

KakaoTalk robot which automatically answer to your command
Python
11
star
43

fraktur

convert the latin alphabet to fraktur unicode characters
Python
11
star
44

comgong-job

A robot for future computer science students
Python
9
star
45

carpedm20

7
star
46

naverdic

NAVER dictionary wrapper for Python
Python
7
star
47

neural-networks-and-deep-learning-ko

Translation of Neural Networks and Deep Learning by Michael Nielsen
6
star
48

ausung

A Data Visualization of Media Sentiments
JavaScript
6
star
49

Easily-written-Django

Easily learn Django to newbies of computer world
Python
6
star
50

Bias

Character-level Bidirectional LSTM for auto spacing (text segmentation)
Lua
5
star
51

quotes

JavaScript
5
star
52

nn-study

Lua
4
star
53

140min-python

140๋ถ„์˜ Python
JavaScript
4
star
54

i-crawl-news

i crawler news
Python
4
star
55

Run-Length-Prediction-of-Change-Point-by-Text-Features

Reading documents for bayesian Online Change Point Detection
HTML
4
star
56

ggomggom-email

Chrome extension for Korean grammer checker
JavaScript
4
star
57

korean-japanese-translator

Korean-Japanese translator using word2vec
Python
3
star
58

all-about-critics

A Data Visualization of Korean movie critics.
Python
3
star
59

jsSolar

Javascript solar system simulator
JavaScript
3
star
60

blog

CSS
3
star
61

UNIST-portal-bot

Facebook bot that uploads portal announcements automatically
Python
2
star
62

2014-study

2014-study
2
star
63

BufferTest_v2

Java
2
star
64

UNIST-FedEx

์œ ๋‹ˆ์ŠคํŠธ ๋‚ด๊ฐ€ ์ „ํ•ด์ฃผ๊นŒ
Python
2
star
65

bap-15min-before

๋ฐฅ๋จน๊ธฐ ์‹ญ์˜ค๋ถ„์ „ - ์œ ๋‹ˆ์ŠคํŠธ
Python
2
star
66

coursera-downloader

course material downloader from coursera
2
star
67

babo

๋ฐ”๋ณด (์‚ฌ์ „)
Python
2
star
68

movie-parser

movie parser
Python
2
star
69

random-wall

A jQuery plugin that randomly changes background-image of an element
JavaScript
2
star
70

basehangul

BaseHangul for GoLang
Go
2
star
71

vec2movie

Python
1
star
72

agora

Cloud commenting system.
Python
1
star
73

FoodDuk

Big data analysis for restaurant recommendation
JavaScript
1
star
74

Study-of-Computer-Vision

Study of Computer Vision
Python
1
star
75

UNIST-auction

UNIST auction
Python
1
star
76

UNIST-robot

easy to access UNIST portal, black board, library
C#
1
star
77

blackbot

blackbot
Python
1
star
78

comgong-abroad

A robot for future computer science students
Python
1
star
79

machine-learning

Study of Machine learning
Python
1
star
80

samantha

Python
1
star
81

FoodClassifier-matlab

Food image classifier written by Matlab
MATLAB
1
star