Experiments and Runs

Azure ML is a cloud-based machine-learning solution that makes it easier to execute your code. A Run is an abstraction layer that wraps around each such submission and is used to keep track of your findings and monitor the task in real time.

Create an experiment in your workspace ws.

ScriptRunConfig

ScriptRunConfig, which bundles your source code (Script) and run settings, is a typical approach to run programmes on the cloud (RunConfig).

For your code, consider the arrangement below.

source_directory/
    script.py    # entry point to your code
    module1.py   # modules called by script.py     
    ...

To run script.py in the cloud via the ScriptRunConfig

where:

Submit this code to Azure with the following code

This will provide you a URL to watch your run on the web (https://ml.azure.com) as well as logs streaming to your terminal.

Command Line Arguments

Use the arguments option in ScriptRunConfig to send command line parameters to your script. Arguments are given in the form of a list:

which are then passed to the script as command-line arguments as follows:

python script.py first second third ...

This also supports using named arguments:

Arguments can be of type int, float str and can also be used to reference data.

Example: sys.argv

In this example we pass two arguments to our script. If we were running this from the console:

python script.py 0.001 0.9

To use this command as a model argument in ScriptRunConfig: run.py

which can be consumed as usual in our script: script.py

Example: argparse

In this example we pass two named arguments to our script. If we were running this from the console:

python script.py --learning_rate 0.001 --momentum 0.9

To use this command as a model in ScriptRunConfig: run.py

which can be consumed as usual in our script: script.py

Commands

It is possible to provide the explicit command to run : script.py

Setting the argument is the same as this example. script='script.py' in place of the command argument.

This option provides a lot of flexibility. For example:

Using Datasets

via Arguments

Pass a dataset to your ScriptRunConfig as an argument

This mounts the dataset to the run where it can be referenced by script.py.

Run

Interactive

In an interactive setting e.g. a Jupyter notebook

run = exp.start_logging()

Example: Jupyter notebook

A common use case for interactive logging is to train a model in a notebook.

Get Context

A Run is used to track the execution of code in Azure ML. The code that was provided has access to its own run.

Example: Logging metrics to current run context

A common use-case is logging metrics in a training script : train.py

This code will report metrics to its related run when uploaded to Azure ML (e.g. through ScriptRunConfig).