OmniSafe Config#
|
Config class for storing hyperparameters. |
Config#
OmniSafe use yaml file to store all the configurations. The configuration file is stored in omnisafe/configs
. The configuration file is divided into several parts.
Take PPOLag
as an example, the configuration file is as follows:
Config |
Description |
|
Training configurations. |
|
Algorithm configurations |
|
Logger configurations |
|
Model configurations |
|
Lagrange configurations |
Specifically, the train_cfgs
is as follows:
Config |
Description |
Value |
|
Device to use. |
|
|
Number of threads to use. |
16 |
|
Number of vectorized environments. |
1 |
|
Number of parallel agent, similar to A3C. |
1 |
|
Total number of training steps. |
1000000 |
Other configurations are similar to train_cfgs
. You can refer to the omnisafe/configs
for more details.
Documentation
- class omnisafe.utils.config.Config(**kwargs)[source]#
Config class for storing hyperparameters.
OmniSafe uses a Config class to store all hyperparameters. OmniSafe store hyperparameters in a yaml file and load them into a Config object. Then the Config class will check the hyperparameters are valid, then pass them to the algorithm class.
Initialize Config.
- static dict2config(config_dict)[source]#
Convert dictionary to Config.
- Parameters:
config_dict (dict) – dictionary to be converted.
- Return type:
Model Config#
Common Method#
Documentation
- omnisafe.utils.config.get_default_kwargs_yaml(algo, env_id, algo_type)[source]#
Get the default kwargs from
yaml
file.Note
This function search the
yaml
file by the algorithm name and environment name. Make sure your new implemented algorithm or environment has the same name as the yaml file.- Parameters:
algo (str) – algorithm name.
env_id (str) – environment name.
- Return type:
Documentation
Documentation
- omnisafe.utils.config.__check_algo_configs(configs, algo_type)[source]#
Check algorithm configs.
This function is used to check the algorithm configs.
Note
update_iters
must be greater than 0 and must be int.update_cycle
must be greater than 0 and must be int.batch_size
must be greater than 0 and must be int.target_kl
must be greater than 0 and must be float.entropy_coeff
must be in [0, 1] and must be float.gamma
must be in [0, 1] and must be float.cost_gamma
must be in [0, 1] and must be float.lam
must be in [0, 1] and must be float.lam_c
must be in [0, 1] and must be float.clip
must be greater than 0 and must be float.penalty_coeff
must be greater than 0 and must be float.reward_normalize
must be bool.cost_normalize
must be bool.obs_normalize
must be bool.kl_early_stop
must be bool.use_max_grad_norm
must be bool.use_cost
must be bool.max_grad_norm
must be greater than 0 and must be float.adv_estimation_method
must be in [gae
,v-trace
,gae-rtg
,plain
].standardized_rew_adv
must be bool.standardized_cost_adv
must be bool.
- Parameters:
configs (Config) – configs to be checked.
algo_type (str) – algorithm type.
- Return type:
None