All Projects → aimhubio → Aim

aimhubio / Aim

Licence: apache-2.0
Aim — a super-easy way to record, search and compare 1000s of ML training runs

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Aim

Awesome Artificial Intelligence
A curated list of Artificial Intelligence (AI) courses, books, video lectures and papers.
Stars: ✭ 6,516 (+628.86%)
Mutual labels:  reinforcement-learning
Notes
Resources to learn more about Machine Learning and Artificial Intelligence
Stars: ✭ 766 (-14.32%)
Mutual labels:  reinforcement-learning
Deeprec
推荐、广告工业界经典以及最前沿的论文、资料集合/ Must-read Papers on Recommendation System and CTR Prediction
Stars: ✭ 822 (-8.05%)
Mutual labels:  reinforcement-learning
Tensorflow Tutorial
TensorFlow and Deep Learning Tutorials
Stars: ✭ 748 (-16.33%)
Mutual labels:  reinforcement-learning
Osim Rl
Reinforcement learning environments with musculoskeletal models
Stars: ✭ 763 (-14.65%)
Mutual labels:  reinforcement-learning
Coursera
Quiz & Assignment of Coursera
Stars: ✭ 774 (-13.42%)
Mutual labels:  reinforcement-learning
Reinforcement Learning 2nd Edition By Sutton Exercise Solutions
Solutions of Reinforcement Learning, An Introduction
Stars: ✭ 713 (-20.25%)
Mutual labels:  reinforcement-learning
Pygame Learning Environment
PyGame Learning Environment (PLE) -- Reinforcement Learning Environment in Python.
Stars: ✭ 828 (-7.38%)
Mutual labels:  reinforcement-learning
Btgym
Scalable, event-driven, deep-learning-friendly backtesting library
Stars: ✭ 765 (-14.43%)
Mutual labels:  reinforcement-learning
Tradinggym
Trading and Backtesting environment for training reinforcement learning agent or simple rule base algo.
Stars: ✭ 813 (-9.06%)
Mutual labels:  reinforcement-learning
Deeprl Tutorials
Contains high quality implementations of Deep Reinforcement Learning algorithms written in PyTorch
Stars: ✭ 748 (-16.33%)
Mutual labels:  reinforcement-learning
Machine Learning Curriculum
💻 Make machines learn so that you don't have to struggle to program them; The ultimate list
Stars: ✭ 761 (-14.88%)
Mutual labels:  reinforcement-learning
Super Mario Bros A3c Pytorch
Asynchronous Advantage Actor-Critic (A3C) algorithm for Super Mario Bros
Stars: ✭ 775 (-13.31%)
Mutual labels:  reinforcement-learning
Pytorch Rl
Deep Reinforcement Learning with pytorch & visdom
Stars: ✭ 745 (-16.67%)
Mutual labels:  reinforcement-learning
Tensorlayer
Deep Learning and Reinforcement Learning Library for Scientists and Engineers 🔥
Stars: ✭ 6,796 (+660.18%)
Mutual labels:  reinforcement-learning
Pysc2 Examples
StarCraft II - pysc2 Deep Reinforcement Learning Examples
Stars: ✭ 722 (-19.24%)
Mutual labels:  reinforcement-learning
Hands On Meta Learning With Python
Learning to Learn using One-Shot Learning, MAML, Reptile, Meta-SGD and more with Tensorflow
Stars: ✭ 768 (-14.09%)
Mutual labels:  reinforcement-learning
Textworld
​TextWorld is a sandbox learning environment for the training and evaluation of reinforcement learning (RL) agents on text-based games.
Stars: ✭ 895 (+0.11%)
Mutual labels:  reinforcement-learning
Basic reinforcement learning
An introductory series to Reinforcement Learning (RL) with comprehensive step-by-step tutorials.
Stars: ✭ 826 (-7.61%)
Mutual labels:  reinforcement-learning
Chatbot cn
基于金融-司法领域(兼有闲聊性质)的聊天机器人,其中的主要模块有信息抽取、NLU、NLG、知识图谱等,并且利用Django整合了前端展示,目前已经封装了nlp和kg的restful接口
Stars: ✭ 791 (-11.52%)
Mutual labels:  reinforcement-learning

A super-easy way to record, search and compare 1000s of ML training runs

PyPI - Python Version PyPI Package Downloads Issues License

Follow on Twitter


🎉 Try out Aim at play.aimstack.io 🎉

Watch the tutorial video

Join the Aim community on Slack



Integrate seamlessly with your favorite tools

Aim is an open-source comparison tool for AI experiments. With more resources and complex models more experiments are ran than ever. Use Aim to deeply inspect thousands of hyperparameter-sensitive training runs at once.

Getting Started in 3 Steps

Follow the steps below to get started with Aim.

1. Install Aim on your training environment

Prerequisite: You need to have python3 and pip3 installed in your environment before installing Aim

$ pip install aim

2. Integrate Aim with your code

Integrate your Python script
import aim

# Save inputs, hparams or any other `key: value` pairs
aim.set_params(hyperparam_dict, name='hparams') # Passing name argument is optional

...
for step in range(10):
    # Log metrics to visualize performance
    aim.track(metric_value, name='metric_name', epoch=epoch_number)
...

See documentation here.

Integrate PyTorch Lightning
from aim.pytorch_lightning import AimLogger

...
trainer = pl.Trainer(logger=AimLogger(experiment='experiment_name'))
...

See documentation here.

Integrate Keras & tf.keras
import aim

# Save inputs, hparams or any other `key: value` pairs
aim.set_params(param_dict, name='params_name') # Passing name argument is optional

...
model.fit(x_train, y_train, epochs=epochs, callbacks=[
    aim.keras.AimCallback(aim.Session(experiment='experiment_name'))
    
    # Use aim.tensorflow.AimCallback in case of tf.keras
    aim.tensorflow.AimCallback(aim.Session(experiment='experiment_name'))
])
...

See documentation here.

3. Run the training as usual and start Aim UI

Prerequisite: In order to start Aim UI you need to have Docker installed.

$ aim up

Jump to [Overview] [SDK Specifications] [Use Cases]

Overview

Aim helps you to compare 1000s of training runs at once through its framework-agnostic python SDK and performant UI.

While using Aim SDK you create a Session object. It handles the tracking of metrics and parameters.

When the training code is instrumented with Aim SDK's Python Library and ran, Aim creates the .aim repository in your specified path and stores the data. Otherwise the data is created and stored in working directory.

Additionally, Aim SDK also gives you flexibility to:

  • use multiple sessions in one training script to store multiple runs at once. When not initialized explicitly, Aim creates a default session.
  • use experiments to group related runs together. An experiment named default is created otherwise.
  • use integrations to automate tracking

Jump to [Getting Started] [SDK Specifications] [Use Cases]

SDK Specifications

Session

Session is the main object that tracks and stores the metadata (metrics and hyperparams). Use Session to specify custom .aim directory, the experiment from the code or other tracking-specific configs from the code

Class aim.Session()source

Parameters

  • repo - Full path to parent directory of Aim repo - the .aim directory. By default current working directory.
  • experiment - A name of the experiment. By default default. See concepts
  • flush_frequency - The frequency per step to flush intermediate aggregated values of metrics to disk. By default per 128 step.
  • block_termination - If set to True process will wait until all tasks are completed, otherwise pending tasks will be killed at process exit. By default True.
  • run - A name of the run. If run name is not specified, universally unique identifier will be generated.

Returns

  • Session object to attribute recorded training run to.

Methods

  • track() - Tracks metrics within the session

  • set_params() - Sets session params

  • flush() - Flushes intermediate aggregated metrics to disk. This method is called at a given frequency and at the end of the run automatically.

  • close() - Closes the session. If not invoked, the session will be automatically closed when the training is done.

Example

  • Here are a few examples of how to use the aim.Session in code.

track

Session.track(value, name='metric_name' [, epoch=epoch] [, **context_args]) source

Parameters

  • value - the metric value of type int/float to track/log
  • name - the name of the metric of type str to track/log (preferred divider: snake_case)
  • epoch - an optional value of the epoch being tracked
  • context_args - any set of other parameters passed would be considered as key-value context for metrics

Example

aim.track(0.01, name='loss', epoch=43, subset='train', dataset='train_1')
aim.track(0.003, name='loss', epoch=43, subset='val', dataset='val_1')

Once tracked this way, the following search expressions are enabled:

loss if context.subset in (train, val) # Retrieve all losses in both train and val phase
loss if context.subset == train and context.dataset in (train_1) # Retrieve all losses in train phase with given datasets

Please note that any key-value could be used to track this way and enhance the context of metrics and enable even more detailed search.

Search by context example here:

set_params

Session.set_params(dict_value, name) source

Parameters

  • dict_value - Any dictionary relevant to the training
  • name - A name for dictionaries

Example

 # really any dictionary can go here
hyperparam_dict = {
  'learning_rate': 0.0001,
  'batch_siz': 32}
aim.set_params(hyperparam_dict, name='params')

The following params can be used later to perform the following search experssions:

loss if params.learning_rate < 0.01 # All the runs where learning rate is less than 0.01
loss if params.learning_rate == 0.0001 and params.batch_size == 32 # all the runs where learning rate is 0.0001 and batch_size is 32

Note: If the set_params is called several times with the same name all the dictionaries will add up in one place on the UI.

flush

Session.flush() source

Aim calculates intermediate values of metrics for aggregation during tracking. This method is called at a given frequency(see Session) and at the end of the run automatically. Use this command to flush those values to disk manually.

Instrumentation

Use Python Library to instrument your training code to record the experiments.

The instrumentation only takes 2 lines:

import aim

Afterwards, simply use the two following functions to track metrics and any params respectively.

...
aim.track(metric_val, name='metric_name', epoch=current_epoch)
aim.set_params(hyperparam_dict, name='dict_name')
...

Jump to [Getting Started] [Overview] [Use Cases]

Integrations

We have integrated Aim to Tensorflow, Keras and Pytorch Lightning to enable automatic tracking. It allows you to track metrics without the need for explicit track statements.

TensorFlow and Keras

Pass an instance of aim.tensorflow.AimCallback to the trainer callbacks list.

Note: Logging for pure keras is handled by aim.keras.AimCallback

Parameters

  • session - Aim Session instance (optional)

Example

from aim import Session
from aim.tensorflow import AimCallback 
# Use `from aim.keras import AimCallback` in case of keras

...
aim_session = Session(experiment='experiment_name')
model.fit(x_train, y_train, epochs=epochs, callbacks=[
    AimCallback(aim_session)
])
...

TensorFlow v1 full example here
TensorFlow v2 full example here
Keras full example here

PyTorch Lightning

Pass aim.pytorch_lightning.AimLogger instance as logger to pl.Trainer to log metrics and parameters automatically.

Parameters

  • repo - Full path to parent directory of Aim repo - the .aim directory (optional)
  • experiment - A name of the experiment (optional)
  • train_metric_prefix - The prefix of metrics names collected in the training loop. By default train_ (optional)
  • test_metric_prefix - The prefix of metrics names collected in the test loop. By default test_ (optional)
  • val_metric_prefix - The prefix of metrics names collected in the validation loop. By default val_ (optional)
  • flush_frequency - The frequency per step to flush intermediate aggregated values of metrics to disk. By default per 128 step. (optional)

Example

from aim.pytorch_lightning import AimLogger

...
# Initialize Aim PL logger instance
aim_logger = AimLogger(experiment='pt_lightning_exp')

# Log parameters (optional)
aim_logger.log_hyperparams({
  "max_epochs": 10,
})

trainer = pl.Trainer(logger=aim_logger)
trainer.fit(model, train_loader, val_loader)
...

Full example here

Jump to [Getting Started] [Overview] [Use Cases]

Command Line Interface

Aim CLI offers a simple interface to easily organize and record your experiments. Paired with the Python Library, Aim is a powerful utility to record, search and compare AI experiments. Here are the set of commands supported:

Command Description
init Initialize the aim repository.
version Displays the version of aim cli currently installed.
experiment Creates a new experiment to group similar training runs into.
up Runs Aim web UI for the given repo
down Turn off the UI
upgrade Upgrade the UI to its latest version
pull Pull the UI of the given version

init

This step is optional. Initialize the aim repo to record the experiments.

$ aim init

Creates .aim directory to save the recorded experiments to. Running aim init in an existing repository will prompt the user for re-initialization.

Beware: Re-initialization of the repo clears .aim folder from previously saved data and initializes new repo. Note: This command is not necessary to be able to get started with Aim as aim is automatically initializes with the first aim function call.

version

Display the Aim version installed.

$ aim version

experiment

Create new experiments to organize the training runs. Here is how it works:

$ aim experiment COMMAND [ARGS]
Command Args Description
add -n | --name <exp_name> Add new experiment with a given name.
checkout -n | --name <exp_name> Switch/checkout to an experiment with given name.
ls List all the experiments of the repo.
rm -n | --name <exp_name> Remove an experiment with the given name.

Disclaimer: Removing the experiment also removes the recorded experiment runs data.

up

Start the Aim web UI locally. Aim UI is a Docker container that mounts the .aim folder and lets researchers manage, search and start new training runs.

$ aim up [ARGS]
Args Description
-h | --host <host> Specify host address.
-p | --port <port> Specify port to listen to.
-v | --version <version> Version of Aim UI to run. Default latest.
--repo <repo_path> Path to parent directory of .aim repo. Current working directory by default
-d | --detach Run Aim UI in detached mode.
--tf_logs <logs_dir_path> Use Aim to search and compare TensorBoard experiments. More details in TensorBoard Experiments

Disclaimer: UI uses docker container to run and having docker installed in the training environment is mandatory for the UI to run. Most of the environments nowadays have docker preinstalled or installed for other purposes so this should not be a huge obstacle to get started with Aim UI.

Please make sure to run aim up in the directory where .aim is located.

down

Turn off Aim UI manually:

$ aim down [ARGS]
Args Description
--repo <repo_path> Path to parent directory of .aim repo. Current working directory by default

upgrade

Upgrade Aim UI to its latest version:

$ aim upgrade

pull

Pulls Aim UI of the given version:

$ aim pull -v <version>

Jump to [Getting Started] [Overview] [Use Cases]

Use Cases

Searching Experiments

AimQL is a super simple, python-like search that enables rich search capabilities to search experiments. Here are the ways you can search on Aim:

  • Search by experiment name - experiment == {name}
  • Search by run - run.hash == "{run_hash}" or run.hash in ("{run_hash_1}", "{run_hash_2}") or run.archived is True
  • Search by param - params.{key} == {value}
  • Search by context - context.{key} == {value}

Search Examples

  • Display the losses and accuracy metrics of experiments whose learning rate is 0.001:
    • loss, accuracy if params.learning_rate == 0.001
  • Display the train loss of experiments whose learning rate is greater than 0.0001:
    • loss if context.subset == train and params.learning_rate > 0.0001

Check out this demo project deployment to play around with search.

Jump to [Getting Started] [Overview] [SDK Specifications]

TensorBoard Experiments

Easily run Aim on experiments visualized by TensorBoard. Here is how:

$ aim up --tf_logs path/to/logs

This command will spin up Aim on the TensorFlow summary logs and load the logs recursively from the given path. Use tf: prefix to select and display metrics logged with tf.summary in the dashboard, for example tf:accuracy.

Tensorboard search example here

Jump to [Getting Started] [Overview] [Specifications]

Anonymized Telemetry

We constantly seek to improve Aim for the communty. Telementry data helps us immensely by capturing anonymous usage analytics and statistics. You will be notified when you run aim up. The telemetry is collected only on the UI. The python package does not have any telemetry associated with it.

Motivation

Aim UI uses segment's analytics toolkit to collect basic info about the usage:

  • Anonymized stripped-down basic usage analytics;
  • Anonymized number of experiments and run. We constantly improve the storage and UI for performance in case of many experiments. This type of usage analytics helps us to stay on top of the performance problem.
    Note: no analytics is installed on the Aim Python package.

How to opt out

You can turn telemetry off by setting the AIM_UI_TELEMETRY_ENABLED environment variable to 0.

Contributor Guide

Jump to [Getting Started] [Overview] [SDK Specifications]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].