Skip to content

Repository files navigation

WARNING: This repository is no longer maintained.

This project is archived and will not receive further updates, bug fixes, or security patches. Issues and pull requests may not be reviewed.

Use this software at your own risk.


End to End Memory Network

This repository contains a pytorch implementation of end-to-end memory networks (MemNNs). The base MemNN implementation was taken from here.

The model uses the method described in End-To-End Memory Networks.

The tasks are from the bAbI dataset.

MemN2N picture

Requirements

The program is written in Python 3, and uses pytorch, scikit-learn. A GPU is not necessary, but can provide a significant speed up especially during training.

Usage

Use the script fetch_data.sh to fetch the Facebook bAbI dataset.

Train and Evaluate model

python main.py --train 1 --lr 0.001 --hops 3 --eval 1 --saved-model-dir ./saved/ --data-dir ./data/tasks_1-20_v1-2/en-10k --task-number 1
  • --epochs: number of epochs to train for, default : 100
  • --train: to train or not, default : 1
  • --lr: set the learning rate, default : 0.001
  • --hops: number of hops in the memory network, default : 1
  • --eval: evaluate against testing data, default : 1
  • --saved-model-dir: directory to save the model to, default : ./saved/
  • --data-dir: data directory which holds the tasks, default : ./data/tasks_1-20_v1-2/en-10k
  • --task-number: task on which to train, default : 1

There are several command line arguments, the important ones are listed below

  • --joint-training: enable joint training, default: 0
  • --batch-size: batch-size for training, default: 32
  • --embed-size: embedding dimensions, default: 25
  • --anneal-factor: factor to anneal by every 'anneal-epoch(s)', default: 2
  • --anneal-epoch: anneal every anneal-epoch epoch, default: 25
  • --log-epochs: Number of epochs after which to log progress, default: 4
  • --debug: Set to 1 for debugging purposes - print weight and other matrices, default : 0
  • --saved-model-dir: path to folder where trained model will be saved.
  • --cuda: set it to 1 for running on GPU, 0 for CPU.

Refer to memory_network_n2n/main.py for other command line arguments.

Results

TaskTesting Accuracy
199.39
227.92
324.69
495.76
580.44
691.13
782.66
882.15
988.5
1041.43
1190.72
1299.69
1394.25
1497.27
15100
1647.98
1757.15
1873.68
1911.39
2080.84

About

Memory networks (and variants) for medical machine reading

Resources

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages