Python Library

The git-ai library is a Python library for managing experiments in Git AI, offering an experiment manager and a writer compatible with the tensorboard API to write metadata. All Experiments must be started using the git-ai library.

Experiment

The Experiment class is used to create and manage an experiment. This class creates a branch for the experiment and changes to it when an instance is created. All further checkpoints are committed to the created branch.

When used as a context manager, the Experiment class automatically creates a final checkpoint and reverts to the original branch upon exiting. If not in a context manager, it reverts upon the script’s completion.

Users can manually invoke Experiment.checkpoint to create checkpoints, or allow the experiment manager to automatically determine the appropriate times for checkpoint generation.

Writing metadata

The class provides a metadata writer adhering to the tensorboard API, accessible via Experiment.writer.

Example:

The example below shows how the user can use this library to create an experiment:

from git_ai.metrics.experiment import Experiment
 
# Other setup code...
 
with Experiment('exp-001') as experiment:
	  writer = experiment.writer
    # Logs some hyperparameters
	  writer.add_hparams(...)
    # Training code
    for epoch in epoch_count:
        # runs actual batches
        # Logs some value for the current epoch
        writer.add_scalar(...)
        # Generates checkpoint and pushes it.
        experiment.checkpoint(f"Checkpoint {epoch}")