CIFAR-10 MLP
A 3072 → 32 → 10 network trained from scratch for the SMAI assignment. Hidden activation: ReLU; output: 10 logits; dtype: float64. Class order: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck.
Training and evaluation
- Original CIFAR-10 training split: 50,000 images; test split: 10,000 images.
- SGD, learning rate 0.05, batch size 64, 100 epochs, no early stopping.
- True training labels (p=0), base seed 1037, initialisation seed 1038, batch seed 1039.
- Final test accuracy: 42.7200%; macro F1: 0.422888.
- Training run.
Architecture and preprocessing
Flatten a 32 × 32 RGB image in HWC row-major order, convert to float64, and divide by 255.
Subtract the per-feature training mean and divide by the training standard deviation from preprocessing.npz.
Those statistics were computed only on the original 50,000 training images; zero standard deviations use divisor 1.
Files
model.pt: PyTorch state dictionary.model.npz: equivalent NumPy parametersW0,b0,W1,b1; weights use shape (inputs, outputs).preprocessing.npz: float64 arraysmeanandstd, each of length 3072.config.json: architecture, class order, training settings and evaluation metrics.
Loading the PyTorch model
import numpy as np
import torch
from torch import nn
from huggingface_hub import hf_hub_download
repo_id = "ransom32/smai-a4-cifar10-mlp"
model = nn.Sequential(
nn.Linear(3072, 32, dtype=torch.float64),
nn.ReLU(),
nn.Linear(32, 10, dtype=torch.float64),
)
state = torch.load(hf_hub_download(repo_id, "model.pt"),
map_location="cpu", weights_only=True)
model.load_state_dict(state)
model.eval()
stats = np.load(hf_hub_download(repo_id, "preprocessing.npz"))
# image: a uint8 RGB NumPy array with shape (32, 32, 3).
x = image.reshape(1, 3072).astype(np.float64) / 255.0
x = (x - stats["mean"]) / stats["std"]
with torch.no_grad():
logits = model(torch.from_numpy(x))
These results come from one seed and this small architecture.