책 『밑바닥부터 만드는 추론 엔진: Rust로 배우는 AI 인퍼런스 엔지니어링』 (Building an Inference Engine from Scratch) 7장에서 쓰는 손글씨 숫자 분류 모델입니다.
A tiny MNIST classifier used in chapter 7 of the book. It exists so that
readers can run the book's inference engine, badak, without training the
model themselves.
| 구조 / Architecture | 다층 퍼셉트론 784 → 128 → 10, ReLU |
| 파라미터 / Parameters | 101,770 |
| 입력 / Input | 28 × 28 픽셀을 (x / 255 − 0.1307) / 0.3081로 정규화해 784개로 편 것 |
| 출력 / Output | 숫자 0~9에 대한 점수 10개 |
| 시험 정확도 / Test accuracy | 97.64% (10,000장 중 9,764장) |
| 파일 | 내용 |
|---|---|
model.safetensors |
가중치 fc1.weight, fc1.bias, fc2.weight, fc2.bias. 전처리에 쓰는 평균과 표준편차는 메타데이터에 있습니다. |
reference.safetensors |
PyTorch가 계산한 정답. 앞의 16장에 대한 층별 출력(input, fc1, relu, logits)과 시험 데이터 전체의 점수(all_logits), 예측(predictions). |
저장소의 reference/ch07_train_mnist.py로 학습했습니다. PyTorch 2.15.0,
난수 씨앗 0, Adam(학습률 0.001), 배치 64, 5 에폭, CPU.
sh scripts/download_mnist.sh
python reference/ch07_train_mnist.py
같은 스크립트를 실행해도 기계와 PyTorch 버전에 따라 가중치가 조금 다를 수 있습니다. 책의 숫자를 그대로 재현하려면 이 저장소의 파일을 쓰십시오.
학습 재료를 보여 주기 위한 작은 모델입니다. MNIST와 같은 방식으로 가운데 정렬된 흰 숫자, 검은 배경의 28 × 28 그림에서만 잘 동작합니다.
reference.safetensors 507.7 kBmodel.safetensors 407.5 kB