SMAI Assignment 4: MLP, clean labels
Final epoch-100 model compared in Section 1.5 of the assignment. Trained from scratch on CIFAR-10's original 50,000 training images, with the original 10,000 test images used for reporting. Architecture was selected in Section 1.2.5 using validation accuracy; no test-based architecture selection was performed for this experiment.
Architecture: 3072 -> 64 -> 10, ReLU hidden activation, Identity output logits, 197,322 parameters. Training used mean cross-entropy, SGD, learning rate 0.05, batch size 64, one batch per update, 100 epochs, no early stopping, seed 11023, and no label noise.
Final train accuracy: 68.052%; test accuracy: 42.060%; mean test F1: 0.416614. These are single-seed assignment results and are not a production benchmark.
Files
model.pt: PyTorch state dictionary, without optimizer or credentials.weights.npz: equivalent weights and biases, keysW0,b0,W1,b1; eachWhas shape(input_width, output_width).preprocessing.npz: per-column mean and standard deviation fitted on the 50,000 training images after division by 255; zero standard deviations are replaced by 1.config.json: architecture, training settings, class order, preprocessing information, and final metrics.
Load locally
After downloading this folder, run:
import numpy as np
import torch
from torch import nn
model = nn.Sequential(nn.Linear(3072, 64), nn.ReLU(),
nn.Linear(64, 10), nn.Identity())
model.load_state_dict(torch.load("model.pt", map_location="cpu", weights_only=True))
model.eval()
statistics = np.load("preprocessing.npz", allow_pickle=False)
mean = torch.tensor(statistics["mean"], dtype=torch.float32)
std = torch.tensor(statistics["std"], dtype=torch.float32)
# images: uint8 NumPy array with shape (N, 32, 32, 3), RGB.
def predict(images):
x = torch.from_numpy(images.reshape(-1, 3072)).float()
x = (x / 255.0 - mean) / std
with torch.no_grad():
return model(x).argmax(dim=1)
Flatten in HWC row-major order; do not transpose to CHW. Outputs are logits, and the predicted class is their argmax. Class names are recorded in config.json.
- Downloads last month
- 17