1212
TensorFlow-Machine-Learning-Projects/Chapter10 at master · PacktPublishing/TensorFlow-Machine-Learning-Projects · GitHub
Skip to content

Latest commit

 

History

History

README.md

Capsule Networks

This repo consists of an implementation of Capsule Networks as demonstrated by this paper Dynamic Routing Between Capsules on Fashion MNIST dataset.

Installations

  • This code is checked on using native Python 3 with anaconda
  • Create a conda virtual environment and install relevant packages using requirements.txt file
pip install requirements.txt

Python Code Run Instructions

To run the code just execute

python main.py

On CPU the code might take few hours to run. However, if you use GPUs it should be much faster

Dataset

The dataset used for this illustration is Fashion MNIST

Code Details

Code is pretty self explanatory. There are mainly four files in implementation:

  • main.py -- It contains three parts:
    • Train: To train the model
    • Test: Test the model on testing dataset
    • Visualize: Visualize few reconstructed images for further interpretation
  • parameter_config.py -- Contains all the parameter declarations
  • CapsNet.py -- Capsule network implementation.
  • helper_functions.py -- Helper functions. Also contains the squashing and routing functions needed by capsule networks

Note that the model was not tuned for best hyperparameters. Feel free to play around.