--- license: mit tags: - pytorch - image-classification - mnist --- # MNIST MLP Classifier A simple 2-layer MLP trained on MNIST. ## Model Info - Input: 28×28 grayscale image (flattened) - Hidden size: 128, Dropout: 0.2 - Output: 10 classes (digits 0–9) ## Usage ```python import torch import torch.nn as nn class MLP(nn.Module): def __init__(self, hidden_size=128, dropout=0.2): super().__init__() self.net = nn.Sequential( nn.Flatten(), nn.Linear(28*28, hidden_size), nn.ReLU(), nn.Dropout(dropout), nn.Linear(hidden_size, hidden_size), nn.ReLU(), nn.Dropout(dropout), nn.Linear(hidden_size, 10), ) def forward(self, x): return self.net(x) from huggingface_hub import hf_hub_download path = hf_hub_download(repo_id="你的用户名/mnist-mlp", filename="model.pth") model = MLP() model.load_state_dict(torch.load(path, map_location="cpu")) model.eval() ```