Skip to content

Commit d06ba55

Browse files
committed
Update readme with test error and reconstruction results
1 parent f4deba5 commit d06ba55

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,26 @@ The model was trained on the standard [MNIST](http://yann.lecun.com/exdb/mnist/)
3535
**Step 1.**
3636
Clone this repository with ``git`` and install project dependencies.
3737

38-
```
38+
```bash
3939
$ git clone https://github.com/cedrickchee/capsule-net-pytorch.git
4040
$ cd capsule-net-pytorch
4141
$ pip install -r requirements.txt
4242
```
4343

4444
**Step 2.**
4545
Start the training and evaluation:
46-
```
46+
47+
- running on CPU
48+
```bash
4749
$ python main.py
4850
```
4951

52+
- running on GPU
53+
- For example, running on 8 GPUs.
54+
```bash
55+
$ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python main.py --epochs 30 --threads 16 --batch-size 128 --test-batch-size 128
56+
```
57+
5058
**The default hyper parameters:**
5159

5260
| Parameter | Value | CLI arguments |
@@ -68,8 +76,31 @@ $ python main.py
6876
| Regularization coefficient for reconstruction loss | 0.0005 | --regularization-scale 0.0005 |
6977

7078
## Results
71-
- training loss
79+
80+
### Test error
81+
82+
CapsNet classification test error on MNIST. The MNIST average and standard deviation results are reported from 3 trials.
83+
84+
[WIP] The results can be reproduced by running the following commands.
85+
86+
```bash
87+
python main.py --num-routing 1 --regularization-scale 0.0 #CapsNet-v1
88+
python main.py --num-routing 1 --regularization-scale 0.0005 #CapsNet-v2
89+
python main.py --num-routing 3 --regularization-scale 0.0 #CapsNet-v3
90+
python main.py --num-routing 3 --regularization-scale 0.0005 #CapsNet-v4
7291
```
92+
93+
Method | Routing | Reconstruction | MNIST (%) | *Paper*
94+
:---------|:------:|:---:|:----:|:----:
95+
Baseline | -- | -- | -- | *0.39*
96+
CapsNet-v1 | 1 | no | -- | *0.34 (0.032)*
97+
CapsNet-v2 | 1 | yes | -- | *0.29 (0.011)*
98+
CapsNet-v3 | 3 | no | -- | *0.35 (0.036)*
99+
CapsNet-v4 | 3 | yes | -- | *0.25 (0.005)*
100+
101+
### Training loss
102+
103+
```text
73104
# Log from the end of the last epoch.
74105
75106
... ... ... ... ... ... ... ... ... ... ...
@@ -116,15 +147,30 @@ Epoch: 10 [59776/60000 (100%)] Loss: 0.029488
116147
Epoch: 10 [44928/60000 (100%)] Loss: 0.045561
117148
```
118149

119-
- evaluation accuracy
120-
```
150+
### Evaluation accuracy
151+
```text
121152
Test set: Average loss: 0.0004, Accuracy: 9885/10000 (99%)
122153
Checkpoint saved to model_epoch_10.pth
123154
```
124155

156+
### Reconstruction
157+
158+
The results of CapsNet-v4.
159+
160+
Digits at left are reconstructed images.
161+
<table>
162+
<tr>
163+
<td>
164+
<img src="results/reconstructed_images.png"/>
165+
</td>
166+
<td>
167+
</td>
168+
</tr>
169+
</table>
170+
125171
## TODO
126172
- [DONE] Publish results.
127-
- [WIP] More testing.
173+
- [DONE] More testing.
128174
- Separate training and evaluation into independent command.
129175
- Jupyter Notebook version.
130176
- Create a sample to show how we can apply CapsNet to real-world application.

results/reconstructed_images.png

47.5 KB
Loading

0 commit comments

Comments
 (0)