Override a given ParamsDict using a dict, JSON/YAML/CSV string or YAML file.
tfm.hyperparams.override_params_dict(
params, dict_or_string_or_yaml_file, is_strict
)
The logic of the function is outlined below:
- Test that the input is a dict. If not, proceed to 2.
- Tests that the input is a string. If not, raise unknown ValueError
2.1. Test if the string is in a CSV format. If so, parse.
If not, proceed to 2.2.
2.2. Try loading the string as a YAML/JSON. If successful, parse to
dict and use it to override. If not, proceed to 2.3.
2.3. Try using the string as a file path and load the YAML file.
Args |
params
|
a ParamsDict object to be overridden.
|
dict_or_string_or_yaml_file
|
a Python dict, JSON/YAML/CSV string or path to
a YAML file specifying the parameters to be overridden.
|
is_strict
|
a boolean specifying whether override is strict or not.
|
Returns |
params
|
the overridden ParamsDict object.
|
Raises |
ValueError
|
if failed to override the parameters.
|