100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small educational project implements a toy Generative Adversarial Network (GAN)-style training loop in pure NumPy that learns to generate 8×8 grayscale digit-like images from scikit-learn’s built-in digits dataset. The code trains a small generator and discriminator (both simple multilayer perceptrons implemented with NumPy), alternately updating them with SGD. The project emphasises reproducibility, simple diagnostics (fixed-seed sample grids), and checks for diversity and memorisation by computing nearest neighbours to the training set.
This project uses the scikit-learn built-in load_digits dataset (8×8 grayscale digit images). These images are small, low-resolution digit shapes intended for educational use. Generated images are synthetic and derived from this public dataset; you may use them for learning, demonstration and non-commercial coursework purposes consistent with scikit-learn’s data redistribution and citation guidance. This project does not generate or attempt to recreate photographs or identifiable people.
Run the script directly: python project.py. The script prints a JSON object with numeric metrics when finished.
Run pytest in the project directory: pytest -q. Tests check structure, ranges, determinism and a conservative metric floor on the held-out discriminator accuracy.
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| discriminator_accuracy | 1 |
| generator_diversity | 0.4598 |
| mean_nearest_train_dist | 2.0647 |
Read the
discriminator_accuracyvalue with care: the data here is small and synthetic with a planted, learnable structure, so a near-perfect score shows the pipeline works, not that the method would reach this on real data. See Limitations.
This is a toy, educational implementation. The images are 8×8 digits — far smaller and simpler than modern photographic image tasks. The neural nets are small and trained with plain SGD on this tiny dataset: they are intended to teach how adversarial alternating updates can be implemented and inspected, not to produce high-fidelity or general-purpose image generators. No identity or private data is involved.
Possible improvements include using larger convolutional networks, experimenting with different losses (e.g. Wasserstein loss), adding regularisation to reduce memorisation, and visualising training dynamics over checkpoints. Also consider switching to a deep autograd framework (PyTorch/TF) for larger-scale experiments.
Full case study, build steps and evaluation checks: GAN for generating simple images on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code