A deep learning project demonstrating multi-task learning using Keras Functional API, where a single Convolutional Neural Network (CNN) simultaneously learns two tasks from the same input: digit classification and synthetic color prediction.
This implementation showcases how to design multi-output architectures with shared representations, enabling efficient learning across related tasks.
This project builds a multi-output neural network that takes an MNIST image as input and produces:
- Digit classification output (0–9)
- Color classification output (synthetic label generated from input data)
The model leverages:
- Shared convolutional feature extraction layers
- Task-specific output heads
- A skip connection (ResNet-style) to improve gradient flow and representation learning
The architecture is implemented using the Keras Functional API, allowing flexible graph-based model design beyond sequential constraints.
The model follows a shared backbone + branching heads design:
- Convolutional layers for spatial feature extraction
- Non-linear activations
- Feature map transformation into a shared latent representation
- A residual-style connection is introduced using
Add - Helps preserve lower-level features and stabilize training
-
Digit Classification Head
- Fully connected layers
- Softmax activation
- Output: 10 classes
-
Color Classification Head
- Parallel dense layers
- Softmax activation
- Output: synthetic color labels
- Based on the MNIST dataset
- Input: grayscale handwritten digit images
A custom function (generate_data) is used to:
- Assign synthetic color labels to each image
- Create a multi-label dataset
- Return inputs along with two corresponding targets
This transforms a single-task dataset into a multi-task learning setup.
The model is trained to optimize two objectives simultaneously:
- Digit classification loss
- Color classification loss
Each task contributes to the overall loss, encouraging the model to learn:
- Shared representations useful across tasks
- Task-specific refinements via separate output heads
- Separate categorical losses applied to each output
- Combined during training
- Gradient-based optimization (via Keras/TensorFlow backend)
- Backpropagation flows through both shared and task-specific layers
The training process includes:
- Custom Logger callback
- Tracks and prints performance metrics
- TensorBoard integration
- Enables visualization of:
- Loss curves
- Training progression
- Enables visualization of:
The model produces two predictions per input:
| Output Type | Description |
|---|---|
| Digit Prediction | Recognizes the digit (0–9) |
| Color Prediction | Predicts assigned color label |
These outputs demonstrate how a single network can handle multiple learning objectives concurrently.
The notebook includes:
- Sample predictions
- Visualization of model outputs
- Comparison between true and predicted labels
This helps validate:
- Task performance
- Generalization capability
- Effectiveness of shared learning
- Keras Functional API for non-linear architectures
- Multi-output model design
- Multi-task learning
- Shared representation learning
- Residual/skip connections in CNNs
- Custom data pipeline creation
- Training with multiple loss functions
- Model monitoring with TensorBoard
- Designing and implementing multi-task neural networks
- Training models with multiple outputs and objectives
- Understanding how shared layers improve learning efficiency
- Applying architectural techniques like skip connections
- Moving beyond sequential models to graph-based model design
This project serves as a practical implementation of multi-task deep learning, illustrating how a single CNN can be extended to solve multiple related problems efficiently. By combining shared feature extraction with task-specific outputs, it highlights a foundational approach used in more advanced systems such as object detection and multi-modal learning models.