Git Product home page Git Product logo

capsnet-nlp-1's Introduction

CapsNet for Natural Language Processing

A capsule is a group of neurons whose activity vector represents the instantiation parameters of a specific type of entity such as an object or an object part.

This repository shows how to use a CapsNet architecture for Natural Language Prcoessing tasks like sentiment analysis.

Capsules are introduced by Geoffrey Hinton. We use a CapsNet implementation from 苏剑林 as git submodule. The implementation can be found here.

Related work

Here are some papers where capsules and the CapsNet architecture are introduced:

Paper Authors Link
Dynamic Routing Between Capsules Sara Sabour, Nicholas Frosst, Geoffrey E Hinton here
Matrix capsules with EM routing Geoffrey E Hinton et al. here
Transforming Auto-encoders Geoffrey E. HintonAlex Krizhevsky, Sida D. Wang here

Submodules

The CapsNet implementation is included via git submodule. So the first step after cloning this repository is to initialize the git submodules. This can be done via:

git submodule update --init --recursive

IMDB

We use the IMDB dataset for sentiment analysis with CapsNet. We use a bidirectional GRU before the capsnet layer.

The training can be started with:

python3 main.py

It takes several minutes per epoch. It is highly recommended to use a GPU for training. All experiments are done with a GTX 1060 (6GB).

Results

The following experiments are done on IMDB dataset:

  • Model a): we use a bidirectional GRU with a hidden size of 256. Number of capsule is set to 10. Number of routings is set to 3.
Model Best accuracy
a 88,98 %

Requirements

A recent version of Keras, TensorFlow and h5py is needed. Only Python 3.x is currently supported.

Contact (Bugs, Feedback, Contribution and more)

For questions about the capsnet-nlp repository, contact the current maintainer: Stefan Schweter [email protected]. If you want to contribute to the project please refer to the Contributing guide!

License

To respect the Free Software Movement and the enormous work of Dr. Richard Stallman the software in this repository is released under the GNU Affero General Public License in version 3. More information can be found here and in COPYING.

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.