Fashion-MNIST deep CNN (BatchNorm + Dropout)
The model recommended in engomaressam/fashion-mnist-cnn-gradcam, where an MLP, a small CNN, this deep CNN and an augmented variant were compared on the same split and training budget. The weights here were retrained with train.py (same architecture, split, optimiser and callbacks; seed 123) so that they could be published.
Write-up: An image classifier you can trust 80% of the time · Kaggle notebook · omaressam.web.app
Metrics (Fashion-MNIST test set, 10,000 images)
| Metric | Value |
|---|---|
| Accuracy | 0.9367 |
| Macro F1 | 0.9366 |
| Parameters | 288,682 |
| Epochs run / best epoch | 27 / 22 (early stopping on validation loss) |
| Training time | 21.7 min on CPU |
Confidence gate
Keep a prediction only when the top-class probability clears a threshold; send the rest to a reviewer.
| Threshold | Auto-tagged | Accuracy on those |
|---|---|---|
| 0.90 | 84.5% | 98.5% |
| 0.95 | 80.1% | 99.1% |
| 0.99 | 70.6% | 99.6% |
Per class
| Class | Precision | Recall | F1 |
|---|---|---|---|
| T-shirt/top | 0.897 | 0.893 | 0.895 |
| Trouser | 0.997 | 0.986 | 0.991 |
| Pullover | 0.915 | 0.907 | 0.911 |
| Dress | 0.927 | 0.941 | 0.934 |
| Coat | 0.884 | 0.923 | 0.903 |
| Sandal | 0.991 | 0.985 | 0.988 |
| Shirt | 0.820 | 0.793 | 0.806 |
| Sneaker | 0.965 | 0.979 | 0.972 |
| Bag | 0.994 | 0.990 | 0.992 |
| Ankle boot | 0.976 | 0.970 | 0.973 |
Shirts are the hard class; the GitHub repo has the confusion matrix, Grad-CAM maps and the confident mistakes.
Architecture
Three convolutional blocks (conv 3×3 without bias → BatchNorm → ReLU, two convs in the first two blocks, one in the third; max-pool; dropout 0.25) with 32, 64 and 128 filters, then a 128-unit dense layer with dropout 0.4 and a 10-way softmax. Adam 1e-3, batch 128, ReduceLROnPlateau and EarlyStopping(patience=5, restore_best_weights=True).
Use
import numpy as np, tensorflow as tf
from huggingface_hub import hf_hub_download
model = tf.keras.models.load_model(hf_hub_download("omaressamrme/fashion-mnist-deep-cnn", "model.keras"))
(_, _), (x_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()
x = (x_test.astype("float32") / 255.0)[..., None] # (n, 28, 28, 1) in [0, 1]
proba = model.predict(x[:8])
classes = ["T-shirt/top", "Trouser", "Pullover", "Dress", "Coat", "Sandal", "Shirt", "Sneaker", "Bag", "Ankle boot"]
print([classes[i] for i in proba.argmax(1)], proba.max(1).round(3))
Input: 28×28 grayscale images scaled to [0, 1] with a trailing channel axis. Trained with TensorFlow 2.21 / Keras 3; model.keras is the native Keras 3 format.