Giter Club home page Giter Club logo

nvdm's Introduction

Neural Variational Document Model (NVDM) tensorflow implementation


This is the tensorflow implementation of NVDM for the paper: Neural Variational Inference for Text Processing. Yishu Miao, Lei Yu, Phil Blunsom. ICML 2016.

The original code is on torch. Since there are quite a few people asked me questions about the implementation, I have reimplemented the model by tensorflow. Please contact me if you find any problem with this implementation. It is able to achieve better results than the ones reported in the paper.

RCV1-v2 dataset

Please download and uncompress the dataset to:

data/rcv1-v2

Train the Model

python nvdm.py --data_dir data/20news/

nvdm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nvdm's Issues

About the KLD curve

I ran the original code for NVDM and found that the kld loss curve decreased and then quickly increased.

According to the ELBO, B = -KL[q(z|x) || p(z)] + E[p(x|z)]. Maximizing this bound is equivalent to minimizing KL[q(z|x) || p(z)] and maximizing E[p(x|z)]. The KLD curve should approach to zero, because KL[q(z|x) || p(z)] >= 0.

The experimental result is strange.

Python 3 Compatibility Issues

I ran into minor issues when using Python 3.

  1. 'xrange' changed to 'range'
  2. change the lines of the function, 'create_batches'
    from ids=range(data_size) to ids = np.arange(data_size) which consequently, changing the padding line to
    batches.append(np.append(ids[-rest:], ([-1] * (batch_size - rest)))) # -1 as padding

An updated version of Tensorflow changed the matrix multiplication from 'tf.mul' to 'tf.multiply'.

What's the words in ./data/vocabs.new ?

I assume that row number of each word in vocabs.new is the index of the word, and the integer after each word is counts of that word in corpus, am I right ?

About 20news data size?

In the paper, it says that the 20news dataset has 11,314 training and 7,531 test articles.
However, why the data you give in this repository has only 11,268 training and 7,505 test articles?

Bug in perplexity calculation?

Hi! So the perplexity calculation here is (per line 140 from "train" in nvdm.py):
print_ppx = np.exp(loss_sum / word_count)

However, loss_sum is based on the sum of "loss" which is the result of "model.objective" i.e. the sum of reconstruction loss (cross-entropy) and K-L Divergence.
Lines 129-132 from "train" in nvdm.py

_, (loss, kld) = sess.run((optim, 
                                    [model.objective, model.kld]),
                                    input_feed)
          loss_sum += np.sum(loss)

Line 78 the model definition in nvdm.py
self.objective = self.recons_loss + self.kld

I thought Perplexity is usually the exponentiated form of the normalized cross-entropy, so is there a technical reason for using the result of model.objective instead of model.recons_loss to calculate the perplexity or is that a bug? I bet numbers should only get better if this is corrected (as KL Divergence is non-negative)

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.