Giter VIP home page Giter VIP logo

hydrax's Introduction

Hydrax

Static Badge Static Badge

A jax implementation for training models in parallel with different slices of data from a larger dataset.

Like a multiheaded mythological hydra, Hydrax enables each model head to select its own subset of data to learn from a base dataset. More specifically, Hydrax allows for variable sized slices of data to be used inside of each model with them all trained in parallel! This works great for researcher trying to get the most out of a single GPU, but generalizes to larger setups.

The sampling method used in Hydrax makes it such that each model doesn't get stuck continuously sampling the same slice of data if the model number is larger than the slice size.

Installation

  1. git clone [email protected]:csaben/Hydrax.git
  2. cd Hydrax
  3. pip install -e .

For cuda support (i.e. to make it go brr) run optional 4th step

  1. pip install -e ".[cuda]"

Examples

Let's imagine you have 784 datapoints. To then train 784 models from model 1 to model 784, each getting it's model number worth of datapoints (sliced from 0:model_number), we would do as follows:

from hydrax import get_trained_models
import equinox as eqx

import equinox as eqx
from hydrax import get_trained_models

# cross entropy loss
from hydrax.loss import loss

# basic eqx model
from hydrax.nn.nonlinear import NonLinearModel

start_slice = "0_784"
start_idx, end_idx = map(int, start_slice.split("_"))
x_train, y_train = load_data() # your dataloading fn for your dataset
x_train, y_train = x_train[start_idx: end_idx], y_train[start_idx: end_idx]

models = get_trained_models(
    x_train,
    y_train,
    num_models=784,
    model_type=NonLinearModel,
    verbose=True,
    start_slice="0_784",
    loss=loss,
)

# save models as a batch of model
eqx.tree_serialise_leaves(next_filename, models)

The above example is with an MNIST like dataset in mind.

Dependencies

  1. Equinox
  2. Jaxlib
  3. Optax

Contributing

Hydrax currently only supports tasks specifically oriented towards classification (binary crossentropy is built-in). I intend to incorporate NLP support soon, but pull requests are welcome!

hydrax's People

Contributors

csaben avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.