Upload trained MNIST distilled student model
Browse files- README.md +76 -0
- config.json +16 -0
- model.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- pytorch
|
| 4 |
+
- mnist
|
| 5 |
+
- image-classification
|
| 6 |
+
- computer-vision
|
| 7 |
+
- knowledge-distillation
|
| 8 |
+
library_name: pytorch
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# MNIST Distilled Student Model
|
| 12 |
+
|
| 13 |
+
A neural network trained on the MNIST dataset using knowledge distillation from a teacher model.
|
| 14 |
+
|
| 15 |
+
## Model Description
|
| 16 |
+
|
| 17 |
+
This is a StudentNet model trained on MNIST using knowledge distillation with the following architecture:
|
| 18 |
+
- Fully connected: 28 × 28 → 128 → 10 (output)
|
| 19 |
+
- ReLU activation
|
| 20 |
+
|
| 21 |
+
The model was trained using knowledge distillation, combining:
|
| 22 |
+
- KL divergence between student and teacher logits (with temperature scaling)
|
| 23 |
+
- Cross-entropy loss on true labels
|
| 24 |
+
|
| 25 |
+
## Training Details
|
| 26 |
+
|
| 27 |
+
### Training Hyperparameters
|
| 28 |
+
- **Batch size**: 128
|
| 29 |
+
- **Epochs**: 10
|
| 30 |
+
- **Learning rate**: 0.001
|
| 31 |
+
- **Weight decay**: 0.0
|
| 32 |
+
- **Optimizer**: AdamW
|
| 33 |
+
- **Training set size**: 50,000
|
| 34 |
+
- **Validation set size**: 10,000
|
| 35 |
+
- **Test set size**: 10,000
|
| 36 |
+
- **Device**: cuda
|
| 37 |
+
- **Seed**: 42
|
| 38 |
+
|
| 39 |
+
### Distillation Parameters
|
| 40 |
+
- **Temperature**: 3.0
|
| 41 |
+
- **Alpha (KL weight)**: 0.5
|
| 42 |
+
|
| 43 |
+
The loss function is: `loss = alpha × KL_loss + (1 - alpha) × CE_loss`
|
| 44 |
+
|
| 45 |
+
### Results
|
| 46 |
+
- **Test Accuracy**: 0.9785
|
| 47 |
+
- **Test Loss**: 0.0808
|
| 48 |
+
|
| 49 |
+
## Usage
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import torch
|
| 53 |
+
from pathlib import Path
|
| 54 |
+
|
| 55 |
+
# Download the model
|
| 56 |
+
model_path = "model.pt"
|
| 57 |
+
state_dict = torch.load(model_path)
|
| 58 |
+
|
| 59 |
+
# Load into your StudentNet architecture
|
| 60 |
+
# (you'll need to define the StudentNet class from the training script)
|
| 61 |
+
model = StudentNet()
|
| 62 |
+
model.load_state_dict(state_dict)
|
| 63 |
+
model.eval()
|
| 64 |
+
|
| 65 |
+
# Make predictions
|
| 66 |
+
with torch.no_grad():
|
| 67 |
+
predictions = model(images)
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## Dataset
|
| 71 |
+
|
| 72 |
+
The model was trained on the [MNIST dataset](http://yann.lecun.com/exdb/mnist/), which contains 70,000 grayscale images of handwritten digits (0-9), each 28x28 pixels.
|
| 73 |
+
|
| 74 |
+
## Model Card Authors
|
| 75 |
+
|
| 76 |
+
Generated automatically during training.
|
config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "StudentNet",
|
| 3 |
+
"task": "MNIST classification",
|
| 4 |
+
"training_method": "knowledge_distillation",
|
| 5 |
+
"batch_size": 128,
|
| 6 |
+
"epochs": 10,
|
| 7 |
+
"learning_rate": 0.001,
|
| 8 |
+
"weight_decay": 0.0,
|
| 9 |
+
"trainset_size": 50000,
|
| 10 |
+
"temperature": 3.0,
|
| 11 |
+
"alpha": 0.5,
|
| 12 |
+
"seed": 42,
|
| 13 |
+
"device": "cuda",
|
| 14 |
+
"test_accuracy": 0.9785,
|
| 15 |
+
"test_loss": 0.08084478095881059
|
| 16 |
+
}
|
model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90ec13a90e328db6e574865522183f13896bb315895695782e48319f728a9cf0
|
| 3 |
+
size 409353
|