Meta experiment functions
Warnings
Some warnings are irrelevant for this library
set_warnings
set_warnings (logging_level)
Set warnings to be ignored for the given logging level or higher.
Load files and set-up tracking
Fist part of experiment: Log into wandb and load config files
prep_experiment
prep_experiment (project_name:str, libraries_to_track:List[str]=['ddopai'], config_train_name:str='config_train', config_agent_name:str='config_agent', config_env_name:str='config_env')
First stpes to always execute when starting an experiment (using wandb for tracking)
init_wandb
init_wandb (project_name:str)
init wandb
Type | Details | |
---|---|---|
project_name | str |
track_libraries_and_git
track_libraries_and_git (libraries_to_track:List[str], tracking:bool=True, tracking_tool='wandb')
Track the versions of the libraries and the git hash of the repository.
Type | Default | Details | |
---|---|---|---|
libraries_to_track | List | ||
tracking | bool | True | |
tracking_tool | str | wandb | Currenty only wandb is supported |
Returns | None |
import_config
import_config (filename:str, path:str=None)
Import a config file in YAML format
Type | Default | Details | |
---|---|---|---|
filename | str | Name of the file, must be a yaml file | |
path | str | None | Optional path to the file if it is not in the current directory |
Returns | Dict |
transfer_additional_target_to_env
transfer_additional_target_to_env (config_env:Dict, config_agent:Dict)
Transfer the lag window from the agent configuration to the environment configuration
Type | Details | |
---|---|---|
config_env | Dict | |
config_agent | Dict | |
Returns | None |
transfer_lag_window_to_env
transfer_lag_window_to_env (config_env:Dict, config_agent:Dict)
Transfer the lag window from the agent configuration to the environment configuration
Type | Details | |
---|---|---|
config_env | Dict | |
config_agent | Dict | |
Returns | None |
Import data
Import data from the ddop package
get_ddop_data
get_ddop_data (config_env:Dict, overwrite:bool=False)
Standard function to load data provided by the ddop package
download_data
download_data (config_env:Dict, overwrite:bool=False)
Download standard dataset from ddop repository using the DatasetLoader class
Type | Default | Details | |
---|---|---|---|
config_env | Dict | ||
overwrite | bool | False | |
Returns | Tuple |
set_indices
set_indices (config_env:Dict, X:numpy.ndarray)
Set the indices for the validation and test set
Type | Details | |
---|---|---|
config_env | Dict | |
X | ndarray | |
Returns | Tuple |
Set up environment
Some functions to set-up the environment
set_up_env
set_up_env (env_class, raw_data:Tuple, val_index_start:int, test_index_start:int, config_env:Dict, postprocessors:List)
Set up the environment
Type | Details | |
---|---|---|
env_class | ||
raw_data | Tuple | |
val_index_start | int | |
test_index_start | int | |
config_env | Dict | |
postprocessors | List | |
Returns | object |
Set up training
Some functions to set-up the environment
set_up_earlystoppinghandler
set_up_earlystoppinghandler (config_train:Dict)
Set up the early stopping handler
Type | Details | |
---|---|---|
config_train | Dict | |
Returns | object |
Testing
Some functions to test the final model.
prep_and_run_test
prep_and_run_test (agent, environment, agent_dir:str=None, save_dataset:bool=True, save_features:bool=False, dataset_dir:str=None, eval_step_info=False, tracking='wandb')
Test the agent in the environment.
Clean-up
Function to clean-up the experiment script
clean_up
clean_up (agent, environment)
Clean up agent and environment to free up GPU memory
Helper functions
Some functions that are needed to run an experiment
select_agent
select_agent (agent_name:str)
Select an agent class from a list of agent names and return the class
Type | Details | |
---|---|---|
agent_name | str | |
Returns | type |
merge_with_namespace
merge_with_namespace (target_dict, source_dict, target_dict_name)
*Merge source_dict into target_dict, using the keys as namespaces. For example, if target_dict_name is “agent”, the key “agent-epsilon” in source_dict will be merged into target_dict[“epsilon”]. The function is to merge hyperparameters from a config file with the default hyperparameters from the yaml files
Args: target_dict (dict): Target dictionary source_dict (dict): Source dictionary target_dict_name (str): Name of the target dictionary
Returns: dict: Merged dictionary*