stable_learning_control.run

Responsible for creating the CLI for the stable_learning_control package. It can be used to start the training of an algorithm, or run any of the other utilities.

Attributes

RUN_KEYS

SUBSTITUTIONS

MPI_COMPATIBLE_ALGOS

BASE_ALGO_NAMES

Functions

_parse_hyperparameter_variants(exp_val)

Function parses exp config values to make sure that comma/space separated

_parse_exp_cfg(cmd_line_args)

This function parses the cmd line args to see if it contains the exp_cfg

_parse_eval_cfg(cmd_line_args)

This function parses the cmd line args to see if it contains the eval_cfg

_add_backend_to_cmd(cmd)

Adds the backend suffix to the input command.

_process_arg(arg[, backend])

Process an arg by eval-ing it, so users can specify more than just strings at

_add_with_backends(algo_list)

Helper function to build lists with backend-specific function names

_parse_and_execute_grid_search(cmd, args)

Interprets algorithm name and cmd line args into an ExperimentGrid.

run(input_args)

Function that is used to run the experiments. I modified this component

Module Contents

stable_learning_control.run.RUN_KEYS = ['num_cpu', 'data_dir', 'datestamp'][source]
stable_learning_control.run.SUBSTITUTIONS[source]
stable_learning_control.run.MPI_COMPATIBLE_ALGOS = [][source]
stable_learning_control.run.BASE_ALGO_NAMES = ['sac', 'lac', 'latc'][source]
stable_learning_control.run._parse_hyperparameter_variants(exp_val)[source]

Function parses exp config values to make sure that comma/space separated strings (i.e. 5, 3, 2 or 5 3 2)) are recognized as hyperparameter variants.

Parameters:

exp_val (object) – The variable to parse.

Returns:

A hyper parameter string or list.

Returns None if exp_val is None.

Return type:

union[str, list, None]

stable_learning_control.run._parse_exp_cfg(cmd_line_args)[source]

This function parses the cmd line args to see if it contains the exp_cfg flag. If this flag is present it uses the exp_cfg file path (next cmd_line arg) to add any hyperparameters found in this experimental configuration file to the cmd line arguments.

Parameters:

cmd_line_args (list) – The cmd line input arguments.

Returns:

Modified cmd line argument list that also contains any hyperparameters

that were specified in a experimental cfg file.

Return type:

list

Note

This function assumes comma/space separated strings (i.e. 5, 3, 2 or 5 3 2)) to be hyperparmeter variants.

stable_learning_control.run._parse_eval_cfg(cmd_line_args)[source]

This function parses the cmd line args to see if it contains the eval_cfg flag. If this flag is present it uses the eval_cfg file path (next cmd_line arg) to add any hyperparameters found in this eval configuration file to the cmd line arguments.

Parameters:

cmd_line_args (list) – The cmd line input arguments.

Returns:

Modified cmd line argument list that also contains any hyperparameters

that were specified in a eval cfg file.

Return type:

list

Note

This function assumes comma/space separated strings (i.e. 5, 3, 2 or 5 3 2)) to be hyperparmeter variants.

stable_learning_control.run._add_backend_to_cmd(cmd)[source]

Adds the backend suffix to the input command.

Parameters:

cmd (str) – The cmd string.

Returns:

tuple containing:

  • cmd (str): The new cmd.

  • backend (str): The used backend (options: tf2 or pytorch).

Return type:

(tuple)

Raises:

AssertError – Raised when a the TensorFlow backend is requested but TensorFlow is not installed.

stable_learning_control.run._process_arg(arg, backend=None)[source]

Process an arg by eval-ing it, so users can specify more than just strings at the command line (eg allows for users to give functions as args).

Parameters:
  • arg (str) – Input argument.

  • backend (str) – The machine learning backend you want to use. Options are tf2 or torch. By default None, meaning no backend is assumed.

Returns:

Processed input argument.

Return type:

obj

stable_learning_control.run._add_with_backends(algo_list)[source]

Helper function to build lists with backend-specific function names

Parameters:

algo_list (list) – List of algorithms.

Returns:

The algorithms with their backends.

Return type:

list

Interprets algorithm name and cmd line args into an ExperimentGrid.

Parameters:
  • cmd (str) – The requested CLI command.

  • args (list) – The command arguments.

Raises:

ImportError – A custom import error if TensorFlow is not installed.

stable_learning_control.run.run(input_args)[source]

Function that is used to run the experiments. I modified this component compared to the SpiningUp such that I can import it in other modules.

Parameters:

input_args (list) – List with command line argument.