{"id":13936397,"url":"https://github.com/adambielski/CapsNet-pytorch","last_synced_at":"2025-07-19T21:32:36.231Z","repository":{"id":52932616,"uuid":"112397025","full_name":"adambielski/CapsNet-pytorch","owner":"adambielski","description":"PyTorch implementation of NIPS 2017 paper Dynamic Routing Between Capsules","archived":false,"fork":false,"pushed_at":"2021-04-13T11:39:54.000Z","size":290,"stargazers_count":493,"open_issues_count":5,"forks_count":71,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-25T17:04:11.233Z","etag":null,"topics":["capsnet","capsules","deep-learning","dynamic-routing-between-capsules","machine-learning","mnist","pytorch"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adambielski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-28T22:33:57.000Z","updated_at":"2025-04-26T18:18:15.000Z","dependencies_parsed_at":"2022-08-24T14:51:18.892Z","dependency_job_id":null,"html_url":"https://github.com/adambielski/CapsNet-pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adambielski/CapsNet-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambielski%2FCapsNet-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambielski%2FCapsNet-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambielski%2FCapsNet-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambielski%2FCapsNet-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adambielski","download_url":"https://codeload.github.com/adambielski/CapsNet-pytorch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adambielski%2FCapsNet-pytorch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266019657,"owners_count":23864916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capsnet","capsules","deep-learning","dynamic-routing-between-capsules","machine-learning","mnist","pytorch"],"created_at":"2024-08-07T23:02:37.839Z","updated_at":"2025-07-19T21:32:31.224Z","avatar_url":"https://github.com/adambielski.png","language":"Python","funding_links":[],"categories":["Python","Paper implementations｜论文实现","Paper implementations"],"sub_categories":["Other libraries｜其他库:","Other libraries:"],"readme":"# Dynamic Routing Between Capsules - PyTorch implementation\n\nPyTorch implementation of NIPS 2017 paper [Dynamic Routing Between Capsules](https://arxiv.org/abs/1710.09829) from Sara Sabour, Nicholas Frosst and Geoffrey E. Hinton.\n\nThe hyperparameters and data augmentation strategy strictly follow the paper.\n\n## Requirements\n\nOnly [PyTorch](http://pytorch.org/) with torchvision is required (tested on pytorch 0.2.0 and 0.3.0). Jupyter and matplotlib is required to run the notebook with visualizations.\n\n## Usage\n\nTrain the model by running\n\n    python net.py\nOptional arguments and default values:\n\n```\n  --batch-size N          input batch size for training (default: 128)\n  --test-batch-size N     input batch size for testing (default: 1000)\n  --epochs N              number of epochs to train (default: 250)\n  --lr LR                 learning rate (default: 0.001)\n  --no-cuda               disables CUDA training\n  --seed S                random seed (default: 1)\n  --log-interval N        how many batches to wait before logging training\n                          status (default: 10)\n  --routing_iterations    number of iterations for routing algorithm (default: 3)\n  --with_reconstruction   should reconstruction layers be used\n```\n\nMNIST dataset will be downloaded automatically.\n\n## Results\n\nThe network trained with reconstruction and 3 routing iterations on MNIST dataset achieves **99.65%** accuracy on test set. The test loss is still slightly decreasing, so the accuracy could probably be improved with more training and more careful learning rate schedule.\n\n## Visualizations\n\nWe can create visualizations of digit reconstructions from DigitCaps (e.g. Figure 3 in the paper)\n\n![Reconstructions](images/reconstructions.png)\n\n\n\nWe can also visualize what each dimension of digit capsule represents (Section 5.1, Figure 4 in the paper). \n\nBelow, each row shows the reconstruction when one of the 16 dimensions in the DigitCaps representation is tweaked by intervals of 0.05 in the range [−0.25, 0.25].\n\n![Perturbations](images/perturbations.png)\n\nWe can see what individual dimensions represent for digit 7,  e.g. dim6 - stroke thickness, dim11 - digit width, dim 15 - vertical shift.\n\nVisualization examples are provided in a [jupyter notebook](reconstruction_visualization.ipynb)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadambielski%2FCapsNet-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadambielski%2FCapsNet-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadambielski%2FCapsNet-pytorch/lists"}