關於 python 庫config 的相關介紹


最近在在看別人代碼的時候發現有人用了config這個庫來保存一些超參數,超參數的設置在深度學習中是非常重要了。一般的config 庫可以直接通過pip install config 安裝

廢話不多說,直接上一個官網上的簡單樣例;

先創建個配置文件simple.cfg,內容如下:

# The message to print (this is a comment)
message: 'Hello, world!'

 #符號是注釋作用

每行用 : 符號作為分隔符

from config import Config

# You can pass any file-like object; if it has a name attribute,
# that name is used when file format error messages are printed
f = file('simple.cfg')
cfg = Config(f)
print cfg.message

值的話一般是支持字符串,bool行的True和False,以及數字


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM