Building a CNN for image classification: my hands-on deep learning journey
Building a convolutional neural network from scratch in TensorFlow and Keras, to understand first-hand what ML products ask of engineering teams.
Why I started this project
In today’s AI-powered landscape, product managers can no longer afford to be siloed from technical foundations, especially on products that involve machine learning or computer vision.
To strengthen my technical fluency and build a first-hand understanding of image processing and deep learning, I implemented a complete convolutional neural network (CNN) from scratch using TensorFlow and Keras.
My goal was simple: build a CNN that classifies images into two categories (binary classification), and understand every step from preprocessing to prediction.
Objectives
- Build and train a CNN that classifies images into one of two classes
- Use industry-standard tools: TensorFlow 2.x, Keras and
ImageDataGenerator - Apply real-time image augmentation to simulate real-world variance
- Train on a clean, structured dataset through a full deep learning pipeline
Dataset
The dataset followed the standard directory format that Keras’s directory loader expects, and every image was resized to 64 × 64 pixels before training.
Model architecture
Built with Keras’s Sequential() API:
- Input: images of shape (64, 64, 3)
- Layer 1: convolution (32 filters, 3×3 kernel, ReLU)
- Layer 2: max pooling (2×2)
- Layer 3: convolution (32 filters, 3×3 kernel, ReLU)
- Layer 4: max pooling (2×2)
- Layer 5: flatten
- Layer 6: dense (128 units, ReLU)
- Output: dense (1 unit, sigmoid)
Training configuration
- Loss: binary cross-entropy
- Optimiser: Adam
- Metric: accuracy
- Batch size: 32
- Epochs: 25
The model was trained with .fit() on batched data from the directory-based loader.
What I learnt
- Preprocessing matters
- Model depth versus simplicity
- Loss curves are everything
- The intuition behind CNNs
(The data side of this project taught me the most; I wrote about it separately in The model wasn’t the problem. The data was.)
Tech stack
Python 3, TensorFlow 2, Keras (Sequential API), VS Code with Jupyter.
Outcome
- Trained a CNN to perform binary classification on a custom image dataset
- Improved performance using real-time augmentation
- Built an end-to-end vision pipeline, from raw images to a classification output
Why this matters for a product manager
This wasn’t just a technical exercise. It was a deliberate effort to become a better product manager by understanding:
- how deep learning models are built and trained
- what engineering trade-offs look like in real-world ML
- where data friction and iteration bottlenecks happen
- how to scope timelines and communicate requirements better
Final thought
Building something end to end bridged the gap between conceptual understanding and practical ML workflows. If you’re a PM, or want to work on AI-powered products, I’d recommend it: it sharpens your technical empathy and your decision-making.
Want to talk about this, or something like it for your team?
Email me