A Python framework for creating, training, testing and tuning machine learning models.
- Demonstrate experimental patterns related to the testing and tuning of machine learning models
- Provide methods for and examples of repeatable, quantitative measurement of model performance
- Leverage machine learning models to automate the testing and tuning of machine learning models
Some elements of the framework may require external components to be installed and running.
- Docker and Minikube or an alternative local conformant Kubernetes deployment.
- Kubeflow installed and running in the Kubernetes cluster. Instructions can be found here.
- A Kuberenetes secret configured for a GCP service account key. Instructions can be found here.
The framework is tested on Ubuntu 24.04 with Python 3.10.15 and 3.12.3.
NOTE: Tensorflow Extended pipelines do not yet support Python 3.12, so Python 3.10 is recommended.
-
Install required system packages (Ubuntu-specific):
$ sudo apt-get install -y build-essential git pre-commit python3-pip python3-dev
-
If compiling Python from source, additional source libraries may be needed:
$ sudo apt-get install -y libbz2-dev libffi-dev liblzma-dev libsnappy-dev libsqlite3-dev libssl-dev
-
Clone this repository:
$ git clone https://github.com/kpeder/deep-learning-framework.git
-
Optionally, use a virtual environment such as venv, virtualenv or conda. If you want to use a virtual environment, make sure that it is created and activated before continuing.
-
Install required Python packages:
$ make install
-
Run package tests:
$ make test
Make sure you've set your PYTHONPATH:
$ export PYTHONPATH=$(pwd)/src
Run the examples (some are long-running!):
-
Create and train a static model.
$ python3 examples/mnist.py
-
Create and train a Hypermodel.
$ python3 examples/tuner.py
-
Create and train a Hypermodel using multiple threads.
$ python3 examples/mptuner.py
-
Get the best Hyperparameters across trial runs.
$ python3 examples/tquery.py --project-prefix ran --top-trials 3
-
Create a local TFX pipeline.
$ python3 examples/pipeline.py
-
Create a Kubeflow TFX pipeline.
$ python3 examples/kfpipeline.py --gcs-bucket my-gcs-bucket-name
Running with docker can be more benifical as you will only require docker and will not need to adjust your local settings to support items.
-
Build the container
$ docker-compose build
-
Run various commands
Adjust the
MODELPY
enviroment varaible in the docker-compose file to run the command that you wish to execute$ docker-compose up
-
Run the Test run required by the PR commit process.
This will effectively run the same command in a similar structure to the github action.
$ docker-compose -f docker-compose.yaml -f docker-compose.unittest.yaml up
-
Run the container for development purposes
This will allow you to block the container and run commands locally as well, it maps the volume to your local such that the code (not container) can be updated and rerun as required.
$ docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml up
Feel free to contribute to this framework via fork.
- All checks and tests must pass using
make pre-commit; make test
- The contribution must align with architecture decisions
- The contribution should build toward the project's objectives
Issues may be submitted and might be considered for implementation, but there are no guarantees and no service commitment is in place.
This repository is formally Unlicensed. Do what you will with any copy of it.