chanfig 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chanfig/__init__.py +3 -0
- chanfig/config.py +1739 -0
- chanfig-0.0.0.dist-info/LICENSE +1 -0
- chanfig-0.0.0.dist-info/LICENSES/LICENSE.Apache2 +201 -0
- chanfig-0.0.0.dist-info/LICENSES/LICENSE.BSD2 +25 -0
- chanfig-0.0.0.dist-info/LICENSES/LICENSE.BSD3 +29 -0
- chanfig-0.0.0.dist-info/LICENSES/LICENSE.GPL2 +339 -0
- chanfig-0.0.0.dist-info/LICENSES/LICENSE.GPL3 +674 -0
- chanfig-0.0.0.dist-info/LICENSES/LICENSE.MIT +21 -0
- chanfig-0.0.0.dist-info/METADATA +178 -0
- chanfig-0.0.0.dist-info/RECORD +12 -0
- chanfig-0.0.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Zhiyuan Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: chanfig
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Easier Configuration
|
|
5
|
+
Home-page: https://chanfig.danling.org
|
|
6
|
+
Keywords: Machine Learning,Config,Dict
|
|
7
|
+
Author: Zhiyuan Chen
|
|
8
|
+
Author-email: this@zyc.ai
|
|
9
|
+
Maintainer: Zhiyuan Chen
|
|
10
|
+
Maintainer-email: this@zyc.ai
|
|
11
|
+
Requires-Python: >=3,<4
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
+
Project-URL: Documentation, https://chanfig.danling.org
|
|
28
|
+
Project-URL: Repository, https://github.com/ZhiyuanChen/CHANfiG
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# CHANfiG
|
|
32
|
+
|
|
33
|
+
Read this in English: [English](README.md), [简体中文](README.cn.md)
|
|
34
|
+
|
|
35
|
+
在其他语言中阅读本文:[简体中文](README.cn.md)、[English](README.md)
|
|
36
|
+
|
|
37
|
+
[Document site](https://chanfig.danling.org)
|
|
38
|
+
|
|
39
|
+
## Introduction
|
|
40
|
+
|
|
41
|
+
CHANfiG aims to make your configuration easier.
|
|
42
|
+
|
|
43
|
+
There are tons of configurable parameters in training a Machine Learning model.
|
|
44
|
+
To configure all these parameters, researchers usually need to write gigantic config files, sometimes even thousands of lines.
|
|
45
|
+
Most of the configs are just replicates of the default arguments of certain functions, resulting in many unnecessary declarations.
|
|
46
|
+
It is also very hard to alter the configurations.
|
|
47
|
+
One needs to navigate and open the right configuration file, make changes, save and exit.
|
|
48
|
+
These had wasted an incountable[^incountable] amount of precious time ~~and is no doubt a crime~~.
|
|
49
|
+
Using `argparse` could relieve the burdens to some extent, however, it takes a lot of work to make it compatible with existing config files, and its lack of nesting limits its potential.
|
|
50
|
+
CHANfiG would like to make a change.
|
|
51
|
+
|
|
52
|
+
You just run your experiment with arguments, and leave everything else to CHANfiG.
|
|
53
|
+
|
|
54
|
+
CHANfiG is highly inspired by [YACS](https://github.com/rbgirshick/yacs).
|
|
55
|
+
Different to the paradigm of YACS(
|
|
56
|
+
`your code + a YACS config for experiment E (+ external dependencies + hardware + other nuisance terms ...) = reproducible experiment E`),
|
|
57
|
+
The paradigm of CHANfiG is:
|
|
58
|
+
|
|
59
|
+
`your code + command line arguments (+ optional CHANfiG config + external dependencies + hardware + other nuisance terms ...) = reproducible experiment E (+ optional CHANfiG config for experiment E)`
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
CHANfiG has great backward compatibility with previous configs.
|
|
64
|
+
|
|
65
|
+
No matter your old config is json or yaml, you could directly read from them.
|
|
66
|
+
|
|
67
|
+
And if you are using yacs, just replace `CfgNode` with `Config` and enjoy all the additional benefits that CHANfiG provides.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from chanfig import Config
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class Model:
|
|
74
|
+
def __init__(self, encoder, dropout=0.1, activation='ReLU'):
|
|
75
|
+
self.encoder = Encoder(**encoder)
|
|
76
|
+
self.dropout = Dropout(dropout)
|
|
77
|
+
self.activation = getattr(Activation, activation)
|
|
78
|
+
|
|
79
|
+
def main(config):
|
|
80
|
+
model = Model(**config.model)
|
|
81
|
+
optimizer = Optimizer(**config.optimizer)
|
|
82
|
+
scheduler = Scheduler(**config.scheduler)
|
|
83
|
+
dataset = Dataset(**config.dataset)
|
|
84
|
+
dataloader = Dataloader(**config.dataloader)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class TestConfig(Config):
|
|
88
|
+
def __init__(self):
|
|
89
|
+
super().__init__()
|
|
90
|
+
self.data.batch_size = 64
|
|
91
|
+
self.model.encoder.num_layers = 6
|
|
92
|
+
self.model.decoder.num_layers = 6
|
|
93
|
+
self.activation = "GELU"
|
|
94
|
+
self.optim.lr = 1e-3
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if __name__ == '__main__':
|
|
98
|
+
# config = Config.read('config.yaml') # in case you want to read from a yaml
|
|
99
|
+
# config = Config.read('config.json') # in case you want to read from a json
|
|
100
|
+
# existing_configs = {'data.batch_size': 64, 'model.encoder.num_layers': 8}
|
|
101
|
+
# config = Config(**existing_configs) # in case you have some config in dict to load
|
|
102
|
+
config = TestConfig()
|
|
103
|
+
config = config.parse()
|
|
104
|
+
# config.merge('dataset.yaml') # in case you want to merge a yaml
|
|
105
|
+
# config.merge('dataset.json') # in case you want to merge a json
|
|
106
|
+
# note that the value of merge will surpass current values
|
|
107
|
+
config.model.decoder.num_layers = 8
|
|
108
|
+
config.freeze()
|
|
109
|
+
print(config)
|
|
110
|
+
# main(config)
|
|
111
|
+
# config.yaml('config.yaml') # in case you want to save a yaml
|
|
112
|
+
# config.json('config.json') # in case you want to save a json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
All you needs to do is just run a line:
|
|
116
|
+
|
|
117
|
+
```shell
|
|
118
|
+
python main.py --model.encoder.num_layers 8
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
You could also load a default configure file and make changes based on it:
|
|
122
|
+
|
|
123
|
+
```shell
|
|
124
|
+
python main.py --config meow.yaml --model.encoder.num_layers 8
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
If you have made it dump current configurations, this should be in the written file:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
data:
|
|
131
|
+
batch_size: 64
|
|
132
|
+
model:
|
|
133
|
+
encoder:
|
|
134
|
+
num_layers: 8
|
|
135
|
+
decoder:
|
|
136
|
+
num_layers: 8
|
|
137
|
+
activation: GELU
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"data": {
|
|
143
|
+
"batch_size": 64
|
|
144
|
+
},
|
|
145
|
+
"model": {
|
|
146
|
+
"encoder": {
|
|
147
|
+
"num_layers": 8
|
|
148
|
+
},
|
|
149
|
+
"decoder": {
|
|
150
|
+
"num_layers": 8
|
|
151
|
+
},
|
|
152
|
+
"activation": "GELU"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Define the default arguments in function, put alteration in CLI, and leave the rest to CHANfiG.
|
|
158
|
+
|
|
159
|
+
## Installation
|
|
160
|
+
|
|
161
|
+
Install most recent stable version on pypi:
|
|
162
|
+
|
|
163
|
+
```shell
|
|
164
|
+
pip install chanfig
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Install the latest version from source:
|
|
168
|
+
|
|
169
|
+
```shell
|
|
170
|
+
pip install git+https://github.com/ZhiyuanChen/chanfig
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
It works the way it should have worked.
|
|
176
|
+
|
|
177
|
+
[^incountable]: fun fact: time is always incountable.
|
|
178
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
chanfig/__init__.py,sha256=fgSn7a3fsOlDInQ_mw1Am4aJznPD0FGcjfdlHd_yGm0,183
|
|
2
|
+
chanfig/config.py,sha256=Dx6YLvR3LGMYsENKyyi7csQqTjD48B6PJuqOMEqunI0,46103
|
|
3
|
+
chanfig-0.0.0.dist-info/LICENSES/LICENSE.Apache2,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
4
|
+
chanfig-0.0.0.dist-info/LICENSES/LICENSE.BSD3,sha256=04pVVqbRLIBTShRJqfn_y32z6HRaxCEJGL-XOE3lPv0,1520
|
|
5
|
+
chanfig-0.0.0.dist-info/LICENSES/LICENSE.GPL3,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
6
|
+
chanfig-0.0.0.dist-info/LICENSES/LICENSE.MIT,sha256=r9GSPSpivCGY_FkouhaQlI3p6C-dIKxdfpw1RcsZTPs,1069
|
|
7
|
+
chanfig-0.0.0.dist-info/LICENSE,sha256=lUTrEUlpJyMzk3yOm7f9STIoiY0r3Go_LmzhzKc96-g,58
|
|
8
|
+
chanfig-0.0.0.dist-info/LICENSES/LICENSE.BSD2,sha256=XSD8A3aeI-xqU_stApHLxl8DbebGTU7ze3XMKWEvd2Y,1322
|
|
9
|
+
chanfig-0.0.0.dist-info/LICENSES/LICENSE.GPL2,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
10
|
+
chanfig-0.0.0.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
|
|
11
|
+
chanfig-0.0.0.dist-info/METADATA,sha256=d4ph-6ArFc0DBJipLxyfPflrfhkvQ5ZmWCFtZAIEyMc,5790
|
|
12
|
+
chanfig-0.0.0.dist-info/RECORD,,
|