Giter Club home page Giter Club logo

dagger's Introduction

dagger: A Python Framework for Reproducible Machine Learning Experiment Orchestration

License: MIT

dagger is a framework to facilitate reproducible and reusable experiment orchestration in machine learning research.

It allows to build and easily analyze trees of experiment states. Specifically, starting from a root experiment state, dagger records state transitions generated by user-defined transformations (through the use of Recipes). These can include model training, reinitialization, quantization, pruning, learning rate changes, checkpointing, task changes, or any other user-defined action that mutates the state of the model or of the experiment.

This library handles all the experiment history tracking behind the scenes by keeping track of how new experiment states result from transformations of existing states. The full experiment can then be represented as a tree of experiment states. This tree structure enables easy visual inspection and interactive analysis of all models in the various states during or after the experiment creation phase.

Installation

python setup.py

Usage

More in-depth example usage is provided in the tutorials (see tutorials/).

import dagger as dag
from types import MethodType
# Initialize an experiment by defining the type of experiment states it will 
# hold and the directory where they will be stored
exp = dag.Experiment(
    directory='dagger/examples/', 
    state_class=dag.ExperimentState
)


# CUSTOM BLOCK
# Depending on your experiment design, define what it means to initialize an 
# experiment state. In this case, the root state is simply defined by 
# creating a model.
def initialize_state(state):
    from torchvision.models import resnet18
    state.model = resnet18()

# Add this customization to the ExperimentState class (or subclass it to add 
# more functionalities)
dag.ExperimentState.initialize_state = MethodType(initialize_state, 
                                                  dag.ExperimentState)


# create the root ExperimentState
root = exp.spawn_new_tree()


# CUSTOM BLOCK
# Define the action performed by the Recipe by implementing the `run` method.
# In this example, the recipe simply reinitializes the bias in the last 
# fully-connected layer to all zeros. 
def run(recipe, state):
    state.model.fc.bias.data.zero_()
    return state

# Add this customization to the Recipe class (or subclass it to add 
# more functionalities)
dag.Recipe.run = MethodType(run, dag.Recipe)


# Generate a new state as a child of the root state by modifying the model 
# according to the instructions contained in the Recipe's `run` method.
new_state = dag.Recipe()(root)

# Now that this simple graph has been defined (with one root state and a child
# state that only differ in the ) 
exp.run()

Structure

  • Experiment: tree structure that handles the connection and bookkeeping of all experiment states.

  • StaticExperimentTree: reconstructed tree structure (after experiments have been run) that allows state filtering and inspection for analysis purposes.

  • ExperimentState: represents the state of the experiment at a given point in time, after the action that generated it is complete.

  • ExperimentStatePromise: represents a future realization of an experiment state within the experiment graph, before it is executed.

  • Recipe: allows to perform a sequence of state-mutating actions and adds a new node to the graph.

  • Function: allows to perform a non-state-mutating operation that therefore doesn't add a new node to the graph.

Execution Flow Diagram

alt text

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

@mickypaganini

@jzf2101

dagger's People

Contributors

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