MNIST_with_MLP / README.md
chandu1617's picture
Fix model card with YAML metadata
58dc2a6 verified
---
library_name: pytorch
tags:
- mnist
- mlp
- image-classification
- pytorch
license: mit
datasets:
- mnist
metrics:
- accuracy
---
# MNIST MLP (fold-4 best)
**Model**: `ImprovedMLP` (2048 β†’ 1024 β†’ 512 β†’ 256 β†’ 128 β†’ 10)
**File**: `mlp_best_fold4.pth`
**Dataset**: MNIST (mean `0.1307`, std `0.3081`)
## Usage
```python
from huggingface_hub import hf_hub_download
import torch, torch.nn as nn
class ImprovedMLP(nn.Module):
def __init__(self):
super().__init__()
self.net = nn.Sequential(
nn.Flatten(),
nn.Linear(784,2048), nn.LayerNorm(2048), nn.GELU(), nn.Dropout(0.1),
nn.Linear(2048,1024), nn.LayerNorm(1024), nn.GELU(), nn.Dropout(0.1),
nn.Linear(1024,512), nn.LayerNorm(512), nn.GELU(), nn.Dropout(0.1),
nn.Linear(512,256), nn.LayerNorm(256), nn.GELU(),
nn.Linear(256,128), nn.LayerNorm(128), nn.GELU(),
nn.Linear(128,10)
)
def forward(self,x): return self.net(x)
path = hf_hub_download("chandu1617/MNIST_with_MLP", "mlp_best_fold4.pth")
model = ImprovedMLP()
model.load_state_dict(torch.load(path))
model.eval()