This repository contains a series of hands-on labs exploring various deep learning paradigms, including supervised learning, reinforcement learning, and transformers. It was developed and tested locally on a high-performance workstation to ensure smooth execution and compatibility across environments.
The labs are structured as independent Jupyter notebooks and cover the following topics:
- Train MLPs and CNNs on MNIST and CIFAR-10
- Experiment with residual connections and knowledge distillation
- Implement REINFORCE and Deep Q-Network (DQN) agents
- Use OpenAI’s
gymnasiumenvironments for training and evaluation
- Perform sentiment analysis and feature extraction with Hugging Face Transformers (DistilBERT)
- Apply Parameter-Efficient Fine-Tuning (PEFT) methods like LoRA
All experiments were run and validated locally using the following setup:
- GPU: NVIDIA RTX 4070 Ti Super (16 GB VRAM)
- CPU: AMD Ryzen 7 7800X3D
- RAM: 32 GB DDR5 (Corsair Vengeance)
- Storage: NVMe SSD Kingston
This configuration allows for fast model training and smooth interaction with large transformer models.
git clone https://github.com/marcopibbes/DLA_labs_1-2-3
cd LabDLA
⚠️ Note: Due to compatibility issues between libraries, you may need separate environments.
conda create -n dla_lab python=3.12.8 -y
conda activate dla_lab
conda install --file requirements.txt -c conda-forge -y
Every file is accurately commented (+ additional Markdown) in order to give the reader a clear view of the phases of the experiments!
.
├── Lab1-CNNs.ipynb # Supervised learning (MLPs, CNNs)
├── Lab2-DRL.ipynb # Reinforcement learning agents
├── Lab3-Transformers.ipynb # Transformers & PEFT
├── BaseTrainingPipeline.py # Core trainer class
├── SLTrainingPipeline.py # Supervised training pipeline
├── RLTrainingPipeline.py # REINFORCE trainer
├── QLTrainingPipeline.py # DQN trainer
├── MLP.py # MLP and ResMLP definitions
├── CNN.py # CNN and ResCNN definitions
├── data/ # Dataset storage (auto-downloaded)
├── checkpoints/ # Saved models
├── logs/ # TensorBoard logs
└── requirements.txt # Dependency list
- Activate the appropriate Python environment.
- Launch Jupyter:
jupyter lab # or jupyter notebook- Open the desired notebook (
Lab1-CNNs.ipynb,Lab2-DRL.ipynb, orLab3-Transformers.ipynb) and start running the cells.
💡 Tip:
If no checkpoints are available, make sure to comment outpipeline.load()and usepipeline.train()instead.
Each notebook also defines a clear() function to clean temporary data (checkpoints, logs, datasets).
To visualize logs and monitor training:
tensorboard --logdir=./logsThen open http://localhost:6006 in your browser.
All required packages are listed in requirements.txt, including:
torch,torchvision,transformers,tensorboardgymnasium,datasets,scikit-learn,matplotlib,pandas- Utilities for training, evaluation, and visualization
Some dependencies are version-pinned for compatibility and were installed via conda-forge.
- Expect first runs to download datasets and pretrained weights.
- Some visualizations (e.g., Lab 2) may require
pygame. - Tested across Python 3.9 and 3.12.8 environments.
- I found this strange yet useful method: autogenerating some comments using Copilot before the warmup code.
- This helped me to understand more about the context and some choices.
- Obviously, I made sure to have the most solid background possible.
- Told this both for transparency and to be helpful to people like me