|
Download README.md from shyo2/cnn0: direct link, hf CLI and curl.
- Browser
- Download file 2.52 kB
-
https://huggingface.co/shyo2/cnn0/resolve/main/README.md
- Command line
-
hf download hf://shyo2/cnn0/README.md
-
curl -L -o README.md https://huggingface.co/shyo2/cnn0/resolve/main/README.md
2.52 kB
| license: mit | |
| tags: | |
| - image-classification | |
| - mnist | |
| - cnn | |
| - resnet | |
| - pytorch | |
| - experiment | |
| pipeline_tag: image-classification | |
| # a0 โ ์์ CNN vs Residual CNN (MNIST) | |
| ๊น์ด๋ฅผ ๋๋ฆฐ ์์ CNN์ ํ๊ณ(degradation ๋ฌธ์ )๋ฅผ ํ์ธํ๊ณ , residual connection์ด | |
| ์ด๋ฅผ ํด๊ฒฐํ๋์ง ๊ฒ์ฆํ ์คํ ํ๋ก์ ํธ. PyTorch๋ก ์ฒ์๋ถํฐ ๊ตฌํ. | |
| ## Model Description | |
| - **Task**: MNIST ์๊ธ์จ ์ซ์ ๋ถ๋ฅ (28ร28, 10 classes) | |
| - **Architecture**: ์ฑ๋ 64 ๊ณ ์ ์ conv ์คํ. `depth` = ๋ธ๋ก ์(๋ธ๋ก๋น conv 2๊ฐ) | |
| - `PlainBlock`: Conv โ BN โ ReLU โ Conv โ BN โ ReLU | |
| - `ResBlock`: ์ ๊ตฌ์กฐ + skip connection (`out + x`) | |
| - **ํ์ต**: Adam (lr=1e-3) + CosineAnnealingLR, batch=128, 15 epochs | |
| - ๊ฐ์ค์น๋ `runs/depthN[_res][_nobn]/model.pt` (PyTorch state_dict)์ ์ ์ฅ | |
| ## Results | |
| ### BatchNorm ์์ โ best val accuracy | |
| | depth (blocks) | plain CNN | + residual | | |
| |---|---|---| | |
| | 5 | **99.70%** | โ | | |
| | 10 | 99.62% | 99.58% | | |
| | 15 | 99.60% | 99.52% | | |
| | 20 | 99.58% | 99.66% | | |
| | 40 | 98.89% (๋ถ์์ ) | 99.56% | | |
| ### BatchNorm ์์ โ best val accuracy | |
| | depth (blocks) | plain CNN | + residual | | |
| |---|---|---| | |
| | 20 | **11.35% (๋ถ๊ดด)** | 99.39% | | |
| | 40 | **11.35% (๋ถ๊ดด)** | 99.40% | | |
| ์์ธํ ๋ถ์์ [RESULTS.md](RESULTS.md), ๋ฐ์ดํฐ ์ถ์ฒ๋ [DATA.md](DATA.md) ์ฐธ์กฐ. | |
| ## How to use | |
| ```python | |
| import torch | |
| from src.model import CNN | |
| model = CNN(depth=20, use_residual=True, bn=False) | |
| model.load_state_dict(torch.load("runs/depth20_res_nobn/model.pt", weights_only=True)) | |
| model.eval() | |
| ``` | |
| ## Training details | |
| ```bash | |
| # ์: depth20 plain CNN, BN ์์ | |
| python src/train.py --depth 20 --no-bn --epochs 15 | |
| # ์: depth20 residual CNN, BN ์์ | |
| python src/train.py --depth 20 --residual --no-bn --epochs 15 | |
| ``` | |
| ์ฃผ์ ์ต์ : `--depth`(๋ธ๋ก ์), `--residual`, `--no-bn`, `--channels`, `--epochs`, `--batch-size`, `--lr` | |
| ## ๊ตฌ์กฐ | |
| ``` | |
| src/ | |
| model.py # PlainBlock / ResBlock / CNN ๋น๋ | |
| train.py # MNIST ํ์ต ์คํฌ๋ฆฝํธ | |
| plot_results.py # runs/ ์ history.json โ ๋น๊ต ๊ทธ๋ํ ์์ฑ | |
| runs/ # ์คํ๋ณ history.json + model.pt ๊ฐ์ค์น | |
| results/ # ์๊ฐํ PNG | |
| data/ # MNIST (git ์ ์ธ, torchvision ์๋ ๋ค์ด๋ก๋) | |
| ``` | |
| ## ์ฌํ ํ๊ฒฝ | |
| ```bash | |
| python -m venv .venv | |
| .venv/Scripts/pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128 | |
| ``` | |
| ํ ์คํธ ํ๊ฒฝ: PyTorch 2.11.0+cu128, NVIDIA RTX 5070 Ti (CUDA 12.8) | |