Skip to main content

ml-toolkit

Motivation

When working on ML projects, especially supervised learning, there tends to be a lot of repeated code, because in every project, we always want a way to checkpoint our work, visualize loss curves in tensorboard, add additional metrics, and see example output. Some projects we are able to do this better than others. Ideally, we want to have some way to consolidate all of this code into a single place.

The problem is that Pytorch examples are not nearly similar enough. Like most data exploration, we want the ability to modify every part of the codebase to handle different loss metrics, different types of data, or different visualizations based on our data dimensions. Combining everything into a single repository would overcomplicate the underlying logic (making the training loop extremely unreadable, for example). We want to strike a balance between extremely minimalistic / readable code that makes it easy to add extra functionality when needed.

Thus, this project is for developers or ML scientists who want features of a fully-functioning ML pipeline from the beginning. Each project comes with consistent styling, an opinionated way of handling logging, metrics, and checkpointing / resuming training from checkpoints. It also integrates seamlessly with Google Colab and AWS/Google Cloud GPUs.

Try It Out!

The first thing you should do is go into one of the output_*/ folders and try training a model. We currently have two models:

Notable Features

  • In train.py, the code performs some verification checks on all models to make sure you aren't mixing up your batch dimensions.
  • Try stopping it and starting it after a couple epochs - it should resume training from the same place.
  • On tensorboard, loss curves should already be plotting seamlessly across runs.
  • All checkpoints should be available in checkpoints/, which contains activation layers, input data, and best models.
  • Scheduling runs is easy by specifying a file in the configs/ folder.

Evaluation Criteria

The goal is for this repository to contain a series of clean ML examples of different levels of understanding that I can draw from and use as examples, test models, etc. I essentially want to gather all of the best-practice code gists I find or have used in the past, and make them modular and easily imported or exported for later use.

The goal is not for this to be some ML framework built on PyTorch, but to focus on a single researcher/developer workflow and make it very easy to begin working. Great for Kaggle competitions, simple data exploration, or experimenting with different models.

The rough evaluation metric for this repo's success is how fast I can start working on a Kaggle challenge after downloading the data: getting insights on the data, its distributions, running baseline and finetuning models, getting loss curves and plots.

Current Workflow

  1. Edit init_proj.py to your desired configuration.
  2. Run python init_proj.py <project_type>, which creates your files in the output/ directory.
  3. Go into the output directory e.g. cd output/
  4. Depending on your dataset, you may need to paste in your data/ folder and edit dataset.py.
  5. Run train.py, which saves model checkpoints, output predictions, and tensorboards in the same folder.
  6. Start tensorboard using the checkpoints/ folder with tensorboard --logdir=checkpoints/
  7. Start and stop training using python train.py --checkpoint=<checkpoint name>. The code should automatically resume training at the previous epoch and continue logging to the previous tensorboard.
  8. Run python test.py --checkpoint=<checkpoint name> to get final predictions.

Directory Structure

  • configs/
  • src/
    • checkpoints/ (Only created once you run train.py)
    • data/
    • losses/
    • metrics/
    • models/
      • layers/
      • ...
    • visualizations/
    • args.py (Modify default hyperparameters manually)
    • dataset.py (Stub)
    • metric_tracker.py
    • models.py (You may opt to keep all your models in one place instead)
    • preprocess.py (Stub)
    • test.py
    • train.py
    • util.py
    • verify.py
    • viz.py (Stub, create more visualizations if necessary)
  • unit_test/

Goal Workflow

  1. Run python init_proj.py to initialize a repo with a given init.config.
  2. Copy data into data/.
  3. Fill in preprocess.py and dataset.py. (Optional: explore data by running python visualize.py)
  4. (Maybe?) Change const.py to specify input/output dimensions, batch size, etc.
  5. Run train.py, which saves model checkpoints, output predictions, and tensorboards in the same folder. Also automatically starts tensorboard server in a tmux session.
  6. Run test.py to get final predictions.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai-toolkit-0.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_toolkit-0.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file ai-toolkit-0.0.1.tar.gz.

File metadata

  • Download URL: ai-toolkit-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for ai-toolkit-0.0.1.tar.gz
Algorithm Hash digest
SHA256 892919d707222ab33f87efe100f5b4974f170b01910cd181ddebc696c8f53e44
MD5 848fbe7a8f8188a6058d16194f740953
BLAKE2b-256 c85bb3aa5603ef10e50b50ce6d8d2e6ac9221f5255e9afb4265c1f790b1d7fcd

See more details on using hashes here.

File details

Details for the file ai_toolkit-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ai_toolkit-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for ai_toolkit-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fc064dd07dd4c3338600eb931e36142c606d688b75d137096cc041c3718af2a6
MD5 8255e752d1bb3551d663cb831b2534e5
BLAKE2b-256 8e86d7470d06b129deb0d29375a93cc025936cc8b87cdb714b6f65bd27cfade1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.2

2 files

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page