A VGG-style CNN that classifies house-number crops from SVHN (Street View House Numbers) into the digits 0-9. It is the final model of a 17-experiment ablation study that goes from a plain MLP to a regularized CNN, changing one thing at a time.
Code, notebooks, figures and the full write-up of every experiment: github.com/ArthurSilvaDantas/svhn-digits
| Task | which digit (0-9) is in the center of a 32×32 RGB crop |
| Model | VGG-style CNN, 2.2M parameters (experiment E16) |
| Format | PyTorch checkpoint (.pt), 8.8 MB |
| Test accuracy | 97.13% (25,285 / 26,032 images) |
| Calibration | ECE 0.49%: confidence matches accuracy |
| Latency | ~1 ms per image on a laptop CPU, 1 thread |
| License | MIT (SVHN itself is for non-commercial use) |
├── best_model.pt final model (E16), used by default
└── ablations/
├── E1.pt … E17.pt checkpoint of every experiment in the study (same format)
git clone https://github.com/ArthurSilvaDantas/svhn-digits && cd svhn-digits
pip install -r requirements.txt && cd notebooks
from svhn_utils import load_model # shared code of the project notebooks
model, norm, ckpt = load_model("best_model", "cpu") # downloads best_model.pt from this repo
probs = model(norm(x)).softmax(1) # x: uint8 tensor [N, 3, 32, 32]
Any experiment can be loaded the same way: load_model("E1", "cpu") … load_model("E17", "cpu").
[N, 3, 32, 32] RGB, uint8 (0-255). Resize other sizes to 32×32 (bilinear); the digit
should be centered: SVHN labels the middle digit even when neighbours are visible.norm.arch, model_kw, state_dict, normalizer, val_acc, test_acc.| Architecture | 3 blocks of [conv 3×3 → BatchNorm → ReLU] × 2 → max pool, 64-128-256 filters → FC 256 → FC 10 |
| Regularization | Dropout 0.1 after each block and 0.5 in the classifier |
| Augmentation | rotation ±10°, shift ±10%, scale 0.9-1.1, brightness/contrast ±20%; no flip (a mirrored digit is another symbol) |
| Optimization | Adam + OneCycle (max lr 1e-3), batch 128, 40 epochs, best epoch by validation accuracy |
| Data | official SVHN train (90/10 stratified train/val split); test only for reporting; extra not used |
What each step of the study added (validation accuracy):
| Experiment | Validation | Test |
|---|---|---|
| E1 · MLP | 82.58% | 80.02% |
| E3 · LeNet-style CNN | 89.18% | 88.42% |
| E4 · VGG-style CNN | 92.53% | 92.70% |
| E7 · + BatchNorm, Dropout, augmentation | 95.74% | 96.45% |
| E16 · same, wider (this model) | 96.07% | 97.13% |
Biggest gains: MLP → CNN (+6.6 p.p.), stacked 3×3 convolutions (+3.4), Dropout (+2.0). Optimizer, learning-rate schedule and batch size changed less than ±0.4 p.p. All 17 experiments are explained on GitHub.
MIT for the model and code. SVHN (Netzer et al., 2011) is for non-commercial use, so check that before using this model commercially.
Uma CNN no estilo VGG que classifica recortes de números de casas do SVHN (Street View House Numbers) nos dígitos de 0 a 9. É o modelo final de um estudo de ablação com 17 experimentos, que vai de uma MLP simples até uma CNN com regularização, mudando uma coisa por vez.
Código, notebooks, figuras e a documentação completa de cada experimento: github.com/ArthurSilvaDantas/svhn-digits
| Tarefa | qual dígito (0-9) está no centro de um recorte RGB de 32×32 |
| Modelo | CNN estilo VGG, 2,2 milhões de parâmetros (experimento E16) |
| Formato | checkpoint PyTorch (.pt), 8,8 MB |
| Acurácia no teste | 97,13% (25.285 de 26.032 imagens) |
| Calibração | ECE de 0,49%: a confiança corresponde à taxa de acerto |
| Latência | ~1 ms por imagem na CPU de um notebook, 1 thread |
| Licença | MIT (o SVHN em si é de uso não comercial) |
├── best_model.pt modelo final (E16), usado por padrão
└── ablations/
├── E1.pt … E17.pt checkpoint de cada experimento do estudo (mesmo formato)
git clone https://github.com/ArthurSilvaDantas/svhn-digits && cd svhn-digits
pip install -r requirements.txt && cd notebooks
from svhn_utils import load_model # código compartilhado dos notebooks do projeto
model, norm, ckpt = load_model("best_model", "cpu") # baixa o best_model.pt deste repositório
probs = model(norm(x)).softmax(1) # x: tensor uint8 [N, 3, 32, 32]
Qualquer experimento pode ser carregado do mesmo jeito: load_model("E1", "cpu") … load_model("E17", "cpu").
[N, 3, 32, 32] RGB, uint8 (0-255). Reduza outros tamanhos para 32×32 (bilinear); o
dígito deve estar centralizado: o SVHN rotula o dígito do meio mesmo com vizinhos visíveis.norm.arch, model_kw, state_dict, normalizer, val_acc, test_acc.| Arquitetura | 3 blocos de [conv 3×3 → BatchNorm → ReLU] × 2 → max pool, 64-128-256 filtros → FC 256 → FC 10 |
| Regularização | Dropout de 0,1 após cada bloco e de 0,5 no classificador |
| Augmentation | rotação ±10°, translação ±10%, escala 0,9-1,1, brilho/contraste ±20%; sem espelhamento (um dígito espelhado é outro símbolo) |
| Otimização | Adam + OneCycle (lr máxima 1e-3), batch 128, 40 épocas, melhor época pela acurácia de validação |
| Dados | split oficial train do SVHN (divisão 90/10 estratificada em treino/validação); test só para reportar; extra não usado |
| Experimento | Validação | Teste |
|---|---|---|
| E1 · MLP | 82,58% | 80,02% |
| E3 · CNN estilo LeNet | 89,18% | 88,42% |
| E4 · CNN estilo VGG | 92,53% | 92,70% |
| E7 · + BatchNorm, Dropout, augmentation | 95,74% | 96,45% |
| E16 · igual, mais larga (este modelo) | 96,07% | 97,13% |
Maiores ganhos: MLP → CNN (+6,6 p.p.), convs 3×3 empilhadas (+3,4) e Dropout (+2,0). Otimizador, schedule da taxa de aprendizado e tamanho do batch mudaram menos de ±0,4 p.p. Os 17 experimentos estão explicados no GitHub.
MIT para o modelo e o código. O SVHN (Netzer et al., 2011) é de uso não comercial; verifique isso antes de usar o modelo comercialmente.
best_model.pt 9 MBablations/E16.pt 9 MBablations/E2.pt 7 MBablations/E1.pt 7 MBablations/E3.pt 4 MBablations/E10.pt 3 MBablations/E11.pt 3 MBablations/E12.pt 3 MBablations/E13.pt 3 MBablations/E14.pt 3 MBablations/E15.pt 3 MBablations/E6.pt 3 MBablations/E7.pt 3 MBablations/E8.pt 3 MBablations/E9.pt 3 MBablations/E5.pt 3 MBablations/E4.pt 3 MBablations/E17.pt 2 MB