• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    Python
  • Created almost 7 years ago
  • Updated almost 7 years ago

Reviews

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

Repository Details

Semi-Amortized Variational Autoencoders

Code for the paper:
Semi-Amortized Variational Autoencoders
Yoon Kim, Sam Wiseman, Andrew Miller, David Sontag, Alexander Rush

Dependencies

The code was tested in python 3.6 and pytorch 0.2. We also require the h5py package.

Data

The raw datasets can be downloaded from here.

Text experiments use the Yahoo dataset from Yang et al. 2017, which is itself derived from Zhang et al. 2015.

Image experiments use the OMNIGLOT dataset Lake et al. 2015 with preprocessing from Burda et al. 2015.

Please cite the original papers when using the data.

Text

After downloading the data, run

python preprocess_text.py --trainfile data/yahoo/train.txt --valfile data/yahoo/val.txt
--testfile data/yahoo/test.txt --outputfile data/yahoo/yahoo

This will create the *.hdf5 files (data tensors) to be used by the model, as well as the *.dict file which contains the word-to-integer mapping for each word.

The basic model command is

python train_text.py --train_file data/yahoo/yahoo-train.hdf5 --val_file data/yahoo/yahoo-val.hdf5
--gpu 1 --checkpoint_path model-path

where model-path is the path to save the best model and the *.hdf5 files are obtained from running preprocess_text.py. You can specify which GPU to use by changing the input to the --gpu command.

To train the various models, add the following:

  • Autoregressive (i.e. language model): --model autoreg
  • VAE: --model vae
  • SVI: --model svi --svi_steps 20 --train_n2n 0
  • VAE+SVI: --model savae --svi_steps 20 --train_n2n 0 --train_kl 0
  • VAE+SVI+KL: --model savae --svi_steps 20 --train_n2n 0 --train_kl 1
  • SA-VAE: --model savae --svi_steps 20 --train_n2n 1

Number of SVI steps can be changed with the --svi_steps command.

To evaluate, run

python train_text.py --train_from model-path --test_file data/yahoo/yahoo-test.hdf5 --test 1 --gpu 1

Make sure the append the relevant model configuration at test time too.

Images

After downloading the data, run

python preprocess_img.py --raw_file data/omniglot/chardata.mat --output data/omniglot/omniglot.pt

To train, the basic command is

python train_img.py --data_file data/omniglot/omniglot.pt --gpu 1 --checkpoint_path model-path

To train the various models, add the following:

  • Autoregressive (i.e. Gated PixelCNN): --model autoreg
  • VAE: --model vae
  • SVI: --model svi --svi_steps 20
  • VAE+SVI: --model savae --svi_steps 20 --train_n2n 0 --train_kl 0
  • VAE+SVI+KL: --model savae --svi_steps 20 --train_n2n 0 --train_kl 1
  • SA-VAE: --model savae --svi_steps 20 --train_n2n 1

To evaluate, run

python train_img.py --train_from model-path --test 1 --gpu 1

Make sure the append the relevant model configuration at test time too.

Acknowledgements

Some of our code is based on VAE with a VampPrior.

License

MIT

More Repositories

1

annotated-transformer

An annotated implementation of the Transformer paper.
Jupyter Notebook
5,683
star
2

seq2seq-attn

Sequence-to-sequence model with LSTM encoder/decoders and attention
Lua
1,257
star
3

im2markup

Neural model for converting Image-to-Markup (by Yuntian Deng yuntiandeng.com)
Lua
1,203
star
4

pytorch-struct

Fast, general, and tested differentiable structured prediction in PyTorch
Jupyter Notebook
1,107
star
5

sent-conv-torch

Text classification using a convolutional neural network.
Lua
448
star
6

namedtensor

Named Tensor implementation for Torch
Jupyter Notebook
443
star
7

var-attn

Latent Alignment and Variational Attention
Python
326
star
8

sent-summary

300
star
9

neural-template-gen

Python
262
star
10

struct-attn

Code for Structured Attention Networks https://arxiv.org/abs/1702.00887
Lua
237
star
11

NeuralSteganography

STEGASURAS: STEGanography via Arithmetic coding and Strong neURAl modelS
Python
183
star
12

urnng

Python
176
star
13

botnet-detection

Topological botnet detection datasets and graph neural network applications
Python
169
star
14

data2text

Lua
158
star
15

compound-pcfg

Python
127
star
16

cascaded-generation

Cascaded Text Generation with Markov Transformers
Python
127
star
17

TextFlow

Python
116
star
18

boxscore-data

HTML
111
star
19

decomp-attn

Decomposable Attention Model for Sentence Pair Classification (from https://arxiv.org/abs/1606.01933)
Lua
95
star
20

encoder-agnostic-adaptation

Encoder-Agnostic Adaptation for Conditional Language Generation
Python
79
star
21

genbmm

CUDA kernels for generalized matrix-multiplication in PyTorch
Jupyter Notebook
79
star
22

DeepLatentNLP

61
star
23

nmt-android

Neural Machine Translation on Android
Lua
59
star
24

BSO

Lua
54
star
25

hmm-lm

Python
42
star
26

seq2seq-talk

TeX
39
star
27

Talk-Latent

TeX
31
star
28

regulatory-prediction

Code and Data to accompany "Dilated Convolutions for Modeling Long-Distance Genomic Dependencies", presented at the ICML 2017 Workshop on Computational Biology
Python
28
star
29

harvardnlp.github.io

JavaScript
26
star
30

strux

Python
18
star
31

lie-access-memory

Lua
17
star
32

annotated-attention

Jupyter Notebook
15
star
33

DataModules

A state-less module system for torch-like languages
Python
8
star
34

rush-nlp

JavaScript
8
star
35

seq2seq-attn-web

CSS
8
star
36

tutorial-deep-latent

TeX
7
star
37

MemN2N

Torch implementation of End-to-End Memory Networks (https://arxiv.org/abs/1503.08895)
Lua
6
star
38

image-extraction

Extract images from PDFs
Jupyter Notebook
4
star
39

paper-explorer

JavaScript
3
star
40

readcomp

Entity Tracking Improves Cloze-style Reading Comprehension
Python
3
star
41

banded

Sparse banded diagonal matrices for pytorch
Cuda
2
star
42

torax

Python
2
star
43

cs6741

HTML
2
star
44

simple-recs

Python
1
star
45

poser

Python
1
star
46

iclr

1
star
47

cs6741-materials

1
star