Skip to content

Get started on your Machine Learning or Deep Learning projects with the best practices!

Notifications You must be signed in to change notification settings

rayanramoul/ml-project-template

Repository files navigation

Machine Learning Project Template

python pytorch lightning hydra black isort
tests PRs

Click on Use this template to start your own project!


A template for machine learning or deep learning projects.

🧠 Features

  • Easy to implement your own model and dataloader
  • Configurable hyperparameters with Hydra
  • Logging with the solution that fits your needs
  • Works on CPU, multi-GPU, and multi-TPUs

⚙️ Installation

  • Use this repository as a template
  • Clone your repository
  • Run make install to install the dependencies
  • Add your model which inherits from LightningModule in src/models
  • Add your dataset which inherits from Datamodule in src/data
  • Add associated yaml configuration files in configs/ folder following existing examples

🌳 Tree Explained

.
├── commit-template.txt
├── configs
│   ├── callbacks
│   │   ├── default.yaml
│   │   ├── early_stopping.yaml
│   │   ├── model_checkpoint.yaml
│   │   ├── model_summary.yaml
│   │   ├── none.yaml
│   │   └── rich_progress_bar.yaml
│   ├── data
│   │   └── mnist.yaml
│   ├── debug
│   │   ├── default.yaml
│   │   ├── fdr.yaml
│   │   ├── limit.yaml
│   │   ├── overfit.yaml
│   │   └── profiler.yaml
│   ├── eval.yaml
│   ├── experiment
│   │   └── example.yaml
│   ├── extras
│   │   └── default.yaml
│   ├── hparams_search
│   │   └── mnist_optuna.yaml
│   ├── __init__.py
│   ├── local
│   ├── logger
│   │   ├── aim.yaml
│   │   ├── comet.yaml
│   │   ├── csv.yaml
│   │   ├── many_loggers.yaml
│   │   ├── mlflow.yaml
│   │   ├── neptune.yaml
│   │   ├── tensorboard.yaml
│   │   └── wandb.yaml
│   ├── model
│   │   └── mnist.yaml
│   ├── paths
│   │   └── default.yaml
│   ├── trainer
│   │   ├── cpu.yaml
│   │   ├── ddp_sim.yaml
│   │   ├── ddp.yaml
│   │   ├── default.yaml
│   │   ├── gpu.yaml
│   │   └── mps.yaml
│   └── train.yaml
├── data
├── Makefile
├── notebooks
├── pyproject.toml
├── README.md
├── ruff.toml
├── scripts
│   └── example_train.sh
├── src
│   ├── app.py
│   ├── data
│   │   ├── components
│   │   │   └── __init__.py
│   │   ├── __init__.py
│   │   └── mnist_datamodule.py
│   ├── Dockerfile
│   ├── eval.py
│   ├── __init__.py
│   ├── LICENSE
│   ├── models
│   │   ├── components
│   │   │   ├── __init__.py
│   │   │   └── simple_dense_net.py
│   │   ├── __init__.py
│   │   └── mnist_module.py
│   ├── README.md
│   ├── requirements.txt
│   ├── resources
│   │   └── screenshot.png
│   ├── train.py
│   └── utils
│       ├── __init__.py
│       ├── instantiators.py
│       ├── logging_utils.py
│       ├── pylogger.py
│       ├── rich_utils.py
│       └── utils.py
└── tests
    └── conftest.py

🔮 Incoming features for this template

  • Add support for multi-GPU training
  • UV package manager setup
  • pre-commits hooks
  • Hydra instantiation of models and dataloaders
  • Add torch.compile of models
  • Integrate TorchTyping
  • Dockerize the project (Dockerfile, run tests and training through docker, optionally docker-compose)
  • Add example of efficient multi-processing using pool map
  • Add example using polars
  • Implement Einops
  • Example mock tests
  • Util scripts to download dataset from kaggle for example
  • Cloud oriented scripts (launch your training on AWS, GCP, Azure)

🤝 Contributing

For more information on how to contribute to this project, please refer to the CONTRIBUTING.md file.

🌟 Aknowledgements

This template was heavily inspired by great existing ones, like:


But with a few opininated changes and improvements, go check them out!