Practical overview
When it fits
Use it for a code-based MNIST experiment when you want to study dynamic routing or inspect reconstruction behavior, rather than as a general-purpose image-classification service.
Who it is for
- Developers and researchers studying capsule networks and dynamic routing.
- Learners who want to train an MNIST model and explore its digit reconstructions.
Documented uses
- Train a capsule-network baseline for MNIST classification.
- Compare classification experiments using different routing-iteration counts.
- Generate input-digit reconstructions with optional reconstruction layers.
- Visualize how changes to individual digit-capsule dimensions affect reconstructions.
Requirements & limits
The repository is public and identifies a BSD-3-Clause license.
- The training example is specific to MNIST handwritten digits.
- Core requirements are PyTorch and torchvision; notebook visualizations also require Jupyter and matplotlib.
- The README documents older tested PyTorch versions, 0.2.0 and 0.3.0.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Train the capsule network on MNIST
Run the documented training script with optional settings for routing and reconstruction.
Before you start
- Python environment with PyTorch and torchvision.
- Access to download the MNIST dataset; the script downloads it automatically.
Steps
Run the command below from the project directory.
python net.pyOptionally set documented arguments such as
--epochs,--lr,--routing_iterations, or--with_reconstruction.
Expected outcome
The script trains and tests the capsule network on MNIST, with configurable routing iterations and optional reconstruction layers.
Guide limitations
- The README's reported 99.65% test accuracy is for reconstruction enabled with three routing iterations and is not a result guaranteed for other settings.
- The README notes that test loss was still decreasing for that reported run.
Explore digit reconstructions in the notebook
Use the provided notebook to inspect reconstructions and how digit-capsule dimensions affect them.
Before you start
- Jupyter and matplotlib, in addition to the project’s PyTorch and torchvision requirements.
Steps
Open
reconstruction_visualization.ipynbin Jupyter.Use the notebook examples to view digit reconstructions and perturb digit-capsule dimensions.
Expected outcome
The examples show reconstructed digits and dimension perturbations, including changes associated with stroke thickness, digit width, and vertical position.
Guide limitations
- The documented examples concern MNIST digit reconstructions and the model's 16 digit-capsule dimensions.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 12 November 2026
- Original website title
- adambielski/CapsNet-pytorch · Official homepage title · retained in its source language

