preface
When we write Python projects, especially deep learning projects, it can be confusing to configure a lot of hyperparameters, so we can write the configuration into a YML file and use the HB-config library to manage it easily.
To show respect: github.com/hb-research… . Look at the author of a sentence to summarize the library functions:
- hb-config is utility for easy to configure your python project especially Deep Learning experiments.
The installation
The installation steps are simple and simply invoke the PIP command
$ pip install hb-config
Copy the code
use
Yml configuration file. If you don’t know how to write yML file, you can learn it in five minutes.
project: "hb-config"
example: true
people:
name: "wangda"
sex: "male"
Copy the code
Using Jupyter, call Config from the library to pass the filename:
from hbconfig import Config
Config("myConfig/config.yml")
print(Config)
Copy the code
Results print:
Read config file name: myConfig/config
{
"project": "hb-config",
"example": true,
"people": {
"name": "wangda",
"sex": "male"
}
}
Copy the code
It is important to note that the PyYAML library version may be too high to report an error. Just drop it to 5.4.1.
The values
-
Take the project value:
print(Config.project) Copy the code
Results print:
hb-config Copy the code
-
Take the example value:
print(Config. example) Copy the code
Results print:
True Copy the code
-
Take a person’s name:
print(Config.people.name) Copy the code
Results print:
wangda Copy the code
-
Take the object:
print(Config.people) Copy the code
Results print:
{ "name": "wangda", "sex": "male", "get_tag": "people" } Copy the code