Skip to content

kpeder/deep-learning-framework

Repository files navigation

Python Deep Learning Framework

A Python framework for creating, training, testing and tuning machine learning models.

Objectives

  1. Demonstrate experimental patterns related to the testing and tuning of machine learning models
  2. Provide methods for and examples of repeatable, quantitative measurement of model performance
  3. Leverage machine learning models to automate the testing and tuning of machine learning models

Prerequisites

Some elements of the framework may require external components to be installed and running.

  1. Docker and Minikube or an alternative local conformant Kubernetes deployment.
  2. Kubeflow installed and running in the Kubernetes cluster. Instructions can be found here.
  3. A Kuberenetes secret configured for a GCP service account key. Instructions can be found here.

Configuration

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.

  1. Install required system packages (Ubuntu-specific):

    $ sudo apt-get install -y build-essential git pre-commit python3-pip python3-dev

  2. 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

  3. Clone this repository:

    $ git clone https://github.com/kpeder/deep-learning-framework.git

  4. 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.

  5. Install required Python packages:

    $ make install

  6. Run package tests:

    $ make test

Running the Examples

Make sure you've set your PYTHONPATH:

$ export PYTHONPATH=$(pwd)/src

Run the examples (some are long-running!):

  1. Create and train a static model.

    $ python3 examples/mnist.py

  2. Create and train a Hypermodel.

    $ python3 examples/tuner.py

  3. Create and train a Hypermodel using multiple threads.

    $ python3 examples/mptuner.py

  4. Get the best Hyperparameters across trial runs.

    $ python3 examples/tquery.py --project-prefix ran --top-trials 3

  5. Create a local TFX pipeline.

    $ python3 examples/pipeline.py

  6. Create a Kubeflow TFX pipeline.

    $ python3 examples/kfpipeline.py --gcs-bucket my-gcs-bucket-name

Running the Examples w Docker

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.

  1. Build the container

    $ docker-compose build

  2. 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

  3. 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

  4. 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

Contributing

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.

License

This repository is formally Unlicensed. Do what you will with any copy of it.

About

Framework to implement machine learning experiments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages