speechbrain.utils.check_yaml module
Tests for checking consistency between yaml files and their corresponding training scripts.
- Authors
Mirco Ravanelli 2022
Andreas Nautsch 2022
Summary
Functions:
Checks if the variables self.moduled.var are properly declared in the hparam file. |
|
Checks consistency between the given yaml file (hparams_file) and the script file. |
|
Detects from the input script file (script_file) which of given variables (var_lst) are demanded. |
|
Extracts a variables from start_pattern to end_pattern. |
|
Extracts from the input yaml file (hparams_file) the list of variables that should be used in the script file. |
Reference
- speechbrain.utils.check_yaml.get_yaml_var(hparam_file)[source]
Extracts from the input yaml file (hparams_file) the list of variables that should be used in the script file.
- Parameters
hparam_file (path) – Path of the yaml file containing the hyperparameters.
- Returns
var_list – list of the variables declared in the yaml file (sub-variables are not included).
- Return type
- speechbrain.utils.check_yaml.detect_script_vars(script_file, var_lst)[source]
Detects from the input script file (script_file) which of given variables (var_lst) are demanded.
- speechbrain.utils.check_yaml.check_yaml_vs_script(hparam_file, script_file)[source]
Checks consistency between the given yaml file (hparams_file) and the script file. The function detects if there are variables declared in the yaml file, but not used in the script file.
- Parameters
hparam_file (path) – Path of the yaml file containing the hyperparameters.
script_file (path) – Path of the script file (.py) containing the training recipe.
- Returns
This function returns False if some mismatch is detected and True otherwise. An error is raised to inform about which variable has been declared but not used.
- Return type
Bool
- speechbrain.utils.check_yaml.extract_patterns(lines, start_pattern, end_pattern)[source]
Extracts a variables from start_pattern to end_pattern.
- speechbrain.utils.check_yaml.check_module_vars(hparam_file, script_file, module_key='modules:', module_var='self.modules.')[source]
Checks if the variables self.moduled.var are properly declared in the hparam file.
- Parameters
hparam_file (path) – Path of the yaml file containing the hyperparameters.
script_file (path) – Path of the script file (.py) containing the training recipe.
module_key (string) – String that denoted the start of the module in the hparam file.
module_var (string) – String that denoted the start of the module in the script file.
- Returns
This function returns False if some mismatch is detected and True otherwise. An error is raised to inform about which variable has been used but not declared.
- Return type
Bool