This implementation is fork of https://github.com/XifengGuo/CapsNet-Keras , applied to IMDB texts reviews dataset and Rotten Tomotoes dataset
A Keras implementation of CapsNet in the paper: Sara Sabour, Nicholas Frosst, Geoffrey E Hinton. Dynamic Routing Between Capsules. NIPS 2017
Step 1. Install Keras:
$ pip install keras
Step 2.
Clone this repository with git
.
$ git clone https://github.com/charlieanna/project.git
$ cd CapsNet-Keras
We have analyzed the capsule net on two datasets, imdb and rotten tomotoes dataset. You can check the results of the traning as well as the test results by using the following commands which will run the python files.
- python rotten_cnn.py
- python rotten_capsulenet.py For convolution layer with capsule net
- python rotten_capsulenet.py --model=LSTM
- python rotten_capsulenet.py --model=GRU
- python rotten_capsulenet.py --model=CuDNNLSTM
- python rotten_capsulenet.py --model=CuDNNGRU
- python imdb_cnn.py
- python imdb_capsulenet.py For convolution layer with capsule net
- python imdb_capsulenet.py --model=LSTM
- python imdb_capsulenet.py --model=GRU
- python imdb_capsulenet.py --model=CuDNNLSTM
- python imdb_capsulenet.py --model=CuDNNGRU
Suppose you have trained a model using the above command, then the trained model will be
saved to result/trained_model.h5
. Now just launch the following command to get test results.
$ python capsulenet.py --is_training 0 --weights result/trained_model.h5
It will output the testing accuracy.