A super-easy way to record, search and compare AI experiments.
Check out a LIVE DEMO and a quick VIDEO on what you can achieve with Aim.
- Install Aim in your training environment and init in the project folder
$ pip3 install aim-cli- Import Aim in your training code
import aim
...
aim.set_params(hyperparam_dict, name='params_name')
aim.track(metric_value, name='metric_name', epoch=the_epoch_value)
...- Run the training like you are used to and start the AI Dev Environment
$ aim up- Aim
To install Aim, you need to have python3 and pip3 installed in your environment
- Install Aim python package
$ pip3 install aim-cliIn order to start Aim Development Environment you need to have Docker installed.
$ aim up- Run - A single training run
- Experiment - a group of associated training runs
When the AI training code is instrumented with Aim Python Library and ran, aim automatically creates a .aim directory where the project is located. All the metadata tracked during training via the Python Library is stored in .aim.
Also see aim init - an optional and alternative way to initialize aim repository.
Use Python Library to instrument your training code to record the experiments. The instrumentation only takes 2 lines:
import aimAfterwards, 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')
...aim.track(value, name='metric_name' [, epoch=epoch] [, **context_args]) source
Parameters
- value - the metric value of type
int/floatto track/log - name - the name of the metric of type
strto 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
Examples
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 will be 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 datasetsPlease 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:
aim.set_params(dict_value, name) source
Parameters
- dict_value - Any dictionary relevant to the training
- name - A name for dictionaries
Examples
# 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 32Note: if the set_params is called several times with the same name all the dictionaries will add up in one place on the UI.
Use Session to specify custom .aim directory or the experiment from the code.
Class aim.Session([repo,] [experiment])source
Create session to specify the repo location and/or the experiment.
Parameters
- repo - Full path to parent directory of Aim repo - the
.aimdirectory - experiment - A name of the experiment. See concepts
Returns
- Session object to attribute recorded training run to.
Methods
-
track()- Tracks metrics within the session -
set_params()- Sets session params -
close()- Closes the session. If not invoked, the session will be automatically closed when the training is done.
Examples
- Here are a few examples of how to use the
aim.Sessionin code
Automatic tracking allows you to track metrics without the need for explicit track statements.
Pass an instance of AimTracker.metrics([session]) to keras callbacks.
Parameters
-
session - Aim Session instance(optional)
-
Here is an example
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}"orrun.hash in ("{run_hash_1}", "{run_hash_2}")orrun.archived is True - Search by param -
params.{key} == {value} - Search by context -
context.{key} == {value}
- 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 dev-environment deployment to play around with search.
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 |
This step is optional. Initialize the aim repo to record the experiments.
$ aim initCreates .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.
Display the Aim version installed.
$ aim versionCreate 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.
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 |
|---|---|
-p | --port <port> |
Specify port to listen to. |
-h | --host <host> |
Specify host address. |
-v | --version <version> |
Version of Aim UI to run. Default latest. |
--tf_logs <logs_dir_path> |
Use Aim to search cand 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 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.
Turn off Aim UI manually:
$ aim downUpgrade Aim UI to its latest version:
$ aim upgradePulls Aim UI of the given version:
$ aim pull -v <version>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